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
{{ message }}
Repository navigation
Order of options where there are list options and values #619
The attached file contains the configuration to parse a number of options that consist of list of elements and finally a list of filenames (after the --).
The problem appear when the last option prior to the -- is a list based option. In that case the parser responds with: 'A required value not bound to option name is missing'
The following command line work with the provided C# configuration:
--modules ../utilities/x64/Debug,../auxtool/x64/Debug --outdir ./x64/Debug -- m_xfunit.f03 m_xfunit_assertion.f03
The following command line does not (with the error mentioned above)
--outdir ./x64/Debug --modules ../utilities/x64/Debug,../auxtool/x64/Debug -- m_xfunit.f03 m_xfunit_assertion.f03
Am I overlooking something or is this an issue or limitation in the software?
Regards,
FranHi.
The attached file contains the configuration to parse a number of options that consist of list of elements and finally a list of filenames (after the --).
The problem appear when the last option prior to the -- is a list based option. In that case the parser responds with: 'A required value not bound to option name is missing'
The following command line work with the provided C# configuration:
--modules ../utilities/x64/Debug,../auxtool/x64/Debug --outdir ./x64/Debug -- m_xfunit.f03 m_xfunit_assertion.f03
The following command line does not (with the error mentioned above)
--outdir ./x64/Debug --modules ../utilities/x64/Debug,../auxtool/x64/Debug -- m_xfunit.f03 m_xfunit_assertion.f03
Am I overlooking something or is this an issue or limitation in the software?
Hi Mohamed,
I am sorry but I have to disagree with your statement. From the design point of view the use of -- should make a difference. The list of items after --modules should be interrupted by the presence of -- where the list of final values in the command line should be started. Otherwise, the presence or absence of -- would make no difference whatsoever.
I have inspected the code and indeed the tokenizer simply ignores the presence of the -- in the command line and then your statement is true that the two lists cannot be told from each other.
I have implemented a small modification (attached) that make the it works in the way I expected (both cases in my original issue behave in the same way as I would expected. It essentially keeps the presence of the -- as an empty token that interrupts the list of items after the --module tag.
The modification is just a trick most likely not good enough for the final implementation but please consider the principle behind. For the time being I'll keep it as workaround in my version.
Kind regards,
Fran
P.S. What different it makes to set value index to 0? I could not find the actual use in the available documentation (maybe my fault not looking in the right place)
From the design point of view the use of -- should make a difference. The list of items after --modules should be interrupted by the presence of -- where the list of final values in the command line should be started. Otherwise, the presence or absence of -- would make no difference whatsoever.
DoubleDash -- is,in all getopt like tools including this library, used to stop processing Named options and considering them as Values.
All values (until the next -option /--option )is collected in one buffer.
so, your case after dashdash is values:
The next custom type can be used instead of IEnumerable, values can be separated by any char (like separator property for IEnumerable<>)
publicclassValueList{// separator between values, space is not allowed. Separators can't be include in valuespublicvirtualchar[]Separator{get;set;}=new[]{',',';',':'};publicIEnumerable<string>Value{get;}publicValueList(stringvalue)=>Value=value.Split(Separator);}
Options can be modified as:
publicclassCommandLineOptions{//default is false, no need for Default=false[Option("verbose",Required=false,HelpText="Generate process tracing information")]publicboolVerbose{get;set;}[Option("outdir",Required=false,Default=".",HelpText="Directory to look for object file")]publicStringOutDir{get;set;}[Option("modules",Required=true,HelpText="Directories to look for module file")]publicValueListModuleDirs{get;set;}[Option("ignore",Required=false,HelpText="List of additional module name references to ignore")]publicValueListIgnores{get;set;}//index 0, because it's the first value starting zero index[Value(0,Required=true,HelpText="List of Fortran source files to process")]publicValueListSrcs{get;set;}}
In this way Srcs ,ModuleDirs and Ignores can be parsed correctly.
This should be fixed in the upcoming 2.9 release; you'll need to add EnableDashDash = true to your parser settings to turn on the special handling of the -- separator. Right now that won't fix the bug, but in 2.9 (upcoming) there's a feature to allow the -- to prevent sequences before the -- from consuming values after the --, which should fix this issue.
There's now a fix for this bug in #684 that does not force you to use EnableDashDash = true. Hopefully #684 will get merged in in time for the upcoming 2.9 release.
Activity
moh-hassan commentedon May 23, 2020
The parser can't isolate the value after list of values because there is no logic rule for value separation.
The solution:
Note: set value index = 0
ffadrique commentedon May 23, 2020
Hi Mohamed,
I am sorry but I have to disagree with your statement. From the design point of view the use of -- should make a difference. The list of items after --modules should be interrupted by the presence of -- where the list of final values in the command line should be started. Otherwise, the presence or absence of -- would make no difference whatsoever.
I have inspected the code and indeed the tokenizer simply ignores the presence of the -- in the command line and then your statement is true that the two lists cannot be told from each other.
I have implemented a small modification (attached) that make the it works in the way I expected (both cases in my original issue behave in the same way as I would expected. It essentially keeps the presence of the -- as an empty token that interrupts the list of items after the --module tag.
The modification is just a trick most likely not good enough for the final implementation but please consider the principle behind. For the time being I'll keep it as workaround in my version.
Kind regards,
Fran
P.S. What different it makes to set value index to 0? I could not find the actual use in the available documentation (maybe my fault not looking in the right place)
Tokenizer.cs.txt
InstanceBuilder.cs.txt
moh-hassan commentedon May 23, 2020
Hi ffadrique
DoubleDash -- is,in all getopt like tools including this library, used to stop processing Named options and considering them as Values.
All values (until the next -option /--option )is collected in one buffer.
so, your case after dashdash is values:
All these values will be merged together.
I will separate the parts of command with | as seen by any getopt like parser, just for visualization:
EDIT:
Really, this issue is reported by more than one: #454, #91 .
A feature will be added to use dashdash as a separator of values
CustumType can help in resolving this use case.
I will provide this solution a little bit
moh-hassan commentedon May 30, 2020
The next custom type can be used instead of IEnumerable, values can be separated by any char (like separator property for IEnumerable<>)
Options can be modified as:
In this way Srcs ,ModuleDirs and Ignores can be parsed correctly.
rmunn commentedon Aug 20, 2020
This should be fixed in the upcoming 2.9 release; you'll need to add
EnableDashDash = trueto your parser settings to turn on the special handling of the--separator. Right now that won't fix the bug, but in 2.9 (upcoming) there's a feature to allow the--to prevent sequences before the--from consuming values after the--, which should fix this issue.Fix enumerable options grabbing too many values
rmunn commentedon Aug 20, 2020
There's now a fix for this bug in #684 that does not force you to use
EnableDashDash = true. Hopefully #684 will get merged in in time for the upcoming 2.9 release.