-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order of options where there are list options and values #619
Comments
The parser can't isolate the value after list of values because there is no logic rule for value separation.
|
Hi Mohamed, 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) |
Hi ffadrique
DoubleDash -- is,in all getopt like tools including this library, used to stop processing Named options and considering them as 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: CustumType can help in resolving this use case. |
The next custom type can be used instead of IEnumerable, values can be separated by any char (like separator property for IEnumerable<>) public class ValueList
{
// separator between values, space is not allowed. Separators can't be include in values
public virtual char[] Separator { get; set; } = new[] { ',', ';', ':' };
public IEnumerable<string> Value { get; }
public ValueList(string value) => Value = value.Split(Separator);
} Options can be modified as: public class CommandLineOptions
{
//default is false, no need for Default=false
[Option("verbose", Required = false, HelpText = "Generate process tracing information")]
public bool Verbose { get; set; }
[Option("outdir", Required = false, Default = ".", HelpText = "Directory to look for object file")]
public String OutDir { get; set; }
[Option("modules", Required = true, HelpText = "Directories to look for module file")]
public ValueList ModuleDirs { get; set; }
[Option("ignore", Required = false, HelpText = "List of additional module name references to ignore")]
public ValueList Ignores { 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")]
public ValueList Srcs { 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 |
Hi.
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?
Regards,
Fran
CommandLineOptions.cs.txt
The text was updated successfully, but these errors were encountered: