https://github.com/mildc055ee/consoleinput.jl
minimal stdin wrapper
https://github.com/mildc055ee/consoleinput.jl
julia
Last synced: 6 months ago
JSON representation
minimal stdin wrapper
- Host: GitHub
- URL: https://github.com/mildc055ee/consoleinput.jl
- Owner: mildc055ee
- License: mit
- Created: 2019-06-05T13:30:53.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-20T10:01:55.000Z (about 6 years ago)
- Last Synced: 2025-01-20T17:29:39.254Z (over 1 year ago)
- Topics: julia
- Language: Julia
- Size: 12.7 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ConsoleInput.jl
[](https://travis-ci.com/mildc055ee/ConsoleInput.jl)
[](https://codecov.io/gh/mildc055ee/ConsoleInput.jl)
minimal stdin wrapper for julia.
## APIs
This module uses original type `DlmType` defined as below.
```julia
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.
```julia
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.
```julia
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.
```julia
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]
```