You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you very much for argc. I have adopted it as my "go-to" command parser.
Summary
I have encountered a use case related to issue #251, in which parsing the command line like GNU getopt would be helpful. I, too, want to use argc to write a wrapper around another CLI tool to which I may wish to pass additional arguments and flags.
The issue arises when there are other arguments defined in addition to # @arg remaining_args~
Environment
MacOS Darwin Kernel Version 23.5.0: arm64
argc 1.19.0
Description
My sample script double-dash-tester.sh appears as follows:
#!/usr/bin/env bash# @describe Testing out the use of double-dash to stop parsing.# @flag -t --test Test flag# @arg first! Search query# @arg second=/tmp# @arg remaining_args~main () {
echo -n "";declare -p argc_test
echo -n "";declare -p argc_first
echo -n "";declare -p argc_second
echo -n "";declare -p argc_remaining_args
}
argc_test=""
argc_remaining_args=()
eval"$(argc --argc-eval "$0""$@")"
With argc 1.19.0, I get the following output using a variety of flags:
$ ./double-dash-tester.sh --
error: the following required arguments were not provided:
<FIRST>
$ ./double-dash-tester.sh -- first second
declare -- argc_test=""declare -- argc_first="first"declare -- argc_second="second"declare -a argc_remaining_args='()'
$ ./double-dash-tester.sh first -- second
declare -- argc_test=""declare -- argc_first="first"declare -- argc_second="second"declare -a argc_remaining_args='()'
$ ./double-dash-tester.sh first second -- -t
declare -- argc_test=""declare -- argc_first="first"declare -- argc_second="second"declare -a argc_remaining_args='([0]="--" [1]="-t")'
I would anticipate the following results if parsing terminated on --:
$ ./double-dash-tester.sh -- first second
error: the following required arguments were not provided:
<FIRST>
$ ./double-dash-tester.sh first -- second
declare -- argc_test=""declare -- argc_first="first"declare -- argc_second="/tmp"declare -a argc_remaining_args='([0]="--" [1]="second")'
$ ./double-dash-tester.sh first second -- -t
declare -- argc_test=""declare -- argc_first="first"declare -- argc_second="second"declare -a argc_remaining_args='([0]="--" [1]="-t")'
I don't assume that the GNU getopt behavior is the goal, but it would be helpful in my use case since I want to pass these arguments after the double-dash on to another command.
The text was updated successfully, but these errors were encountered:
The -- in argc means that all remaining arguments are positional and should not be parsed as options. There is no other meaning besides this.
If you prefer using --, you don't even have to use ~.
- # @arg remaining_args~+ # @arg remaining_args*
$ ./double-dash-tester.sh first second -- -t
declare -- argc_test=""declare -- argc_first="first"declare -- argc_second="second"declare -a argc_remaining_args=([0]="-t")
If you have used ~, you don't need to pass --.
$ ./double-dash-tester.sh first second -t
declare -- argc_test=""declare -- argc_first="first"declare -- argc_second="second"declare -a argc_remaining_args=([0]="-t")
Thank you very much for
argc
. I have adopted it as my "go-to" command parser.Summary
I have encountered a use case related to issue #251, in which parsing the command line like GNU getopt would be helpful. I, too, want to use argc to write a wrapper around another CLI tool to which I may wish to pass additional arguments and flags.
The issue arises when there are other arguments defined in addition to
# @arg remaining_args~
Environment
Description
My sample script
double-dash-tester.sh
appears as follows:With
argc 1.19.0
, I get the following output using a variety of flags:My reading of GNU Standards for Command Line Interfaces and the
getopt
sample code is that argument parsing should terminate upon finding a--
.I would anticipate the following results if parsing terminated on
--
:I don't assume that the GNU getopt behavior is the goal, but it would be helpful in my use case since I want to pass these arguments after the double-dash on to another command.
The text was updated successfully, but these errors were encountered: