-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fromfile_prefix_chars setting, like Python
- Loading branch information
Showing
8 changed files
with
170 additions
and
12 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
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
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
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
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,62 @@ | ||
# test 8: read args from file | ||
|
||
function ap_settings8a() | ||
|
||
s = ArgParseSettings(fromfile_prefix_chars=['@']) | ||
|
||
@add_arg_table s begin | ||
"--opt1" # an option (will take an argument) | ||
"--opt2", "-o" # another option, with short form | ||
"arg1" # a positional argument | ||
end | ||
|
||
s.exc_handler = ArgParse.debug_handler | ||
|
||
return s | ||
end | ||
|
||
function ap_settings8b() # unicode | ||
|
||
s = ArgParseSettings(fromfile_prefix_chars="@∘") | ||
|
||
@add_arg_table s begin | ||
"--opt1" # an option (will take an argument) | ||
"--opt2", "-o" # another option, with short form | ||
"arg1" # a positional argument | ||
end | ||
|
||
s.exc_handler = ArgParse.debug_handler | ||
|
||
return s | ||
end | ||
|
||
let s = ap_settings8a() | ||
ap_test8(args) = parse_args(args, s) | ||
|
||
@compat @test ap_test8(["@args-file1"]) == Dict( | ||
"opt1"=>nothing, "opt2"=>"y", "arg1"=>nothing) | ||
@compat @test ap_test8(["@args-file1", "arg"]) == Dict( | ||
"opt1"=>nothing, "opt2"=>"y", "arg1"=>"arg") | ||
@compat @test ap_test8(["@args-file2"]) == Dict( | ||
"opt1"=>"x", "opt2"=>"y", "arg1"=>nothing) | ||
@compat @test ap_test8(["@args-file2", "arg"]) == Dict( | ||
"opt1"=>"x", "opt2"=>"y", "arg1"=>"arg") | ||
end | ||
|
||
let s = ap_settings8b() | ||
ap_test8(args) = parse_args(args, s) | ||
|
||
@compat @test ap_test8(["∘args-file1"]) == Dict( | ||
"opt1"=>nothing, "opt2"=>"y", "arg1"=>nothing) | ||
@compat @test ap_test8(["@args-file1", "arg"]) == Dict( | ||
"opt1"=>nothing, "opt2"=>"y", "arg1"=>"arg") | ||
@compat @test ap_test8(["∘args-file2"]) == Dict( | ||
"opt1"=>"x", "opt2"=>"y", "arg1"=>nothing) | ||
@compat @test ap_test8(["@args-file2", "arg"]) == Dict( | ||
"opt1"=>"x", "opt2"=>"y", "arg1"=>"arg") | ||
end | ||
|
||
# not allowed | ||
@ap_test_throws ArgParseSettings(fromfile_prefix_chars=['-']) | ||
@ap_test_throws ArgParseSettings(fromfile_prefix_chars=['Å']) | ||
@ap_test_throws ArgParseSettings(fromfile_prefix_chars=['8']) |
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 @@ | ||
--opt2=y |
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,2 @@ | ||
@args-file1 | ||
--opt1=x |
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