Skip to content
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

Longflag should support dash ('-') chars #17

Open
finetjul opened this issue Apr 16, 2013 · 6 comments
Open

Longflag should support dash ('-') chars #17

finetjul opened this issue Apr 16, 2013 · 6 comments

Comments

@finetjul
Copy link
Member

command line applications typically have dashes in the names of their long flags.
It should be possible to have parameters such as:
--no-something
--use-something
...

@millerjv
Copy link
Member

I think "-" is supported. I believe either tclap or GenerateCLP was modified to support "-" in the flag name. It might just be at runtime, i.e. you may have specify it as "" but when run, you can substitute "-" for "".

@finetjul
Copy link
Member Author

Here is the error I have at compile time:

ModuleDescriptionParser Error: <longflag> can only contain letters, numbers and underscores and must start with a _ or letter. The offending name is "number-of-elements" at line 47 while parsing <?xml version="1.0" encoding="utf-8"?>

Here is the interesting part in the xml:

<integer>
      <name>NumberOfElements</name>
      <label>Number of elements</label>
      <flag>-n</flag>
      <longflag>--number-of-elements</longflag>
      <description><![CDATA[Number of elements per tuple (e.g. 3 for an RGB image). 1 by default]]></description>
      <default>1</default>
    </integer>

While GenerateCLP might support it, ModuleDescriptionParser does not.

@millerjv
Copy link
Member

I think you need to "define" the option using "_" (--number_of_elements) but then you can call it with "-" (--number-of-elements).

@jcfr
Copy link
Member

jcfr commented Apr 16, 2013

We should really fix ModuleDescriptionParser, forcing to use "_" doesn't
really make sens anymore I think.

On Tue, Apr 16, 2013 at 1:55 PM, Julien Finet [email protected]:

Here is the error I have at compile time:

ModuleDescriptionParser Error: can only contain letters, numbers and underscores and must start with a _ or letter. The offending name is "number-of-elements" at line 47 while parsing

Here is the interesting part in the xml:

NumberOfElements Number of elements -n --number-of-elements 1

While GenerateCLP might support it, ModuleDescriptionParser does not.


Reply to this email directly or view it on GitHubhttps://github.com//issues/17#issuecomment-16460626
.

+1 919 869 8849

@jcfr
Copy link
Member

jcfr commented Apr 16, 2013

It seems this is more a hidden feature ... considering that documentation
is generated based on the xml, "-" should be allowed but the associated
C/Cpp variable should be "escaped" so that "_" is used instead of any
special chars.

On Tue, Apr 16, 2013 at 1:57 PM, Jim Miller [email protected]:

I think you need to "define" the option using "_" (--number_of_elements)
but then you can call it with "-" (--number-of-elements).


Reply to this email directly or view it on GitHubhttps://github.com//issues/17#issuecomment-16460811
.

+1 919 869 8849

@lassoan
Copy link
Contributor

lassoan commented Sep 8, 2021

This has come up in the Slicer forum (https://discourse.slicer.org/t/hyphen-dash-in-cli-command-long-flag-argument/19526), but - as always - there was an easy workaround (rename arguments). Often renaming the arguments is not necessary because short form of the argument can be used (e.g., the long form --input-file is not compatible with SEM but the short form -i is). If all else fail, then it is always possible to add an adaptor Python script (that takes SEM-compatible argument list and calls the executable with any kind of argument list).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants