ConsoleInput.jl

Minimal stdin wrapper
Author mildc055ee
Popularity
1 Star
Updated Last
4 Years Ago
Started In
June 2019

ConsoleInput.jl

Build Status codecov

minimal stdin wrapper for julia.

APIs

This module uses original type DlmType defined as below.

DlmType = Union{
    AbscractChar,
    AbscractString,
    Regex
}

Default delimiter is " ".You can indicate specific delimiter like readXXX(delimiter=",").

Note This packages function returns a single value when args is only one. else returns array.

readInt(io::IO=stdin, delimiter::DlmType=" ")

parse inputs to Int.

readInt() #<-- 1
#--> 1

readInt() #<-- 1 2 3 4 5
#--> [1, 2, 3, 4, 5]

readInt(delimiter=',') #<--6,7,8,9,10
#--> [6, 7, 8, 9, 10]

readString(io::IO=stdin, delimiter::DlmType=" ")

parse inputs to string.

readString() #<-- Lorem
#--> "Lorem"

readString() #<-- Lorem ipsum es
#-->["Lorem", "ipsum", "es"]

readGeneral(type, io::IO=stdin, delimiter::DlmType=" ")

parse inputs to any types you want. First argument MUST be a type name.

readGeneral(Complex{Fload64}) #<--1.2e-3+4j -9+6.8i 0.0004 90.5im
#-->[0.0012+4.0im, -9.0+6.8im, 0.0004+0.0im, 0.0+90.5im]