Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashercn97/ashparser2.0
An updated CLI building tool! Has more features now:)
https://github.com/ashercn97/ashparser2.0
Last synced: 12 days ago
JSON representation
An updated CLI building tool! Has more features now:)
- Host: GitHub
- URL: https://github.com/ashercn97/ashparser2.0
- Owner: ashercn97
- Created: 2023-10-13T20:23:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-13T21:36:44.000Z (about 1 year ago)
- Last Synced: 2023-10-15T11:44:50.445Z (about 1 year ago)
- Language: Julia
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AshParser2.0
This is a super simple, one-file, easy yet effective CLI library in the Julia language.## What it does
AshParse has features to build arguements and specify the type, generate ```--help``` outputs, default values, positional args, and more!It makes it very easy to create CLI tools (which is shown below!).
#### Step one:
Import the file (I havnet uploaded it to Pkg yet)
```
include("AshParse.jl")
using .ArgParser
```#### Step two:
Next, specify the flags you want to include in your tool.Do this in the format:
```
flags = Dict(
"name" => Flag("name", number_of_args, "description of the flag for the help generation", default_args),
)
```
#### Step three:
Finally, you can find, parse and process the arguements.
1. Get the messy array of arguements called from the command line! Super simple, one line.
```
args = ArgParser.get_array()
```2. Put the args into a temporary structure based on the flags YOU specify (NOTE YOU JUST WRITE THE FLAG NAME, DONT INCLUDE "--")
```
parsed_args = ArgParser.put_in_struct(args, flags)
```3. And last step: process the args into a super easy to use format for all your command line needs.
```
processed_args = ArgParser.process_args(parsed_args, Dict(
"name" => Type,
))
```## Example usage:
```
for arg in processed_args #processed args is an array of structs
if arg.flag == "add" # the flag is the input, for this example it is the add flag
result = arg.value[1] + arg.value[2] # these call the array of values that was put in after
println("Result of addition: $result")
elseif arg.flag == "multiply"
result = arg.value[1] * arg.value[2]
println("Result of multiplication: $result")
end
end
```