-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using ArgMacros | ||
|
||
function main() | ||
@beginarguments begin | ||
@argumentdefault Int 1 opt1 "-o" "--opt1" | ||
@argumentdefault Int 2 opt2 "--opt2" | ||
@argumentflag flag "--flag" | ||
@positionaloptional String arg "arg" | ||
end | ||
|
||
println(" arg=>", arg) | ||
println(" opt1=>", opt1) | ||
println(" opt2=>", opt2) | ||
println(" flag=>", flag) | ||
return | ||
end | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
ArgParse example implemented in Comonicon. | ||
# Arguments | ||
- `x`: an argument, an argument | ||
# Options | ||
- `--opt1 <arg>`: an option | ||
- `-o, --opt2 <arg>`: another option | ||
# Flags | ||
- `-f, --flag`: a flag | ||
""" | ||
function main(x; opt1 = 1, opt2::Int = 2, flag = false) | ||
println("Parsed args:") | ||
println("flag=>", flag) | ||
println("arg=>", x) | ||
println("opt1=>", opt1) | ||
println("opt2=>", opt2) | ||
end | ||
|
||
include(".comonicon.cmd/cmd.jl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Fire | ||
|
||
@main function main(x; opt1 = 1, opt2::Int = 2, flag = false) | ||
println("Parsed args:") | ||
println("flag=>", flag) | ||
println("arg=>", x) | ||
println("opt1=>", opt1) | ||
println("opt2=>", opt2) | ||
end |