Skip to content

What is the correct way to parse an argument with value - #574

Closed

Description

@tevoinea

I have a program that I would like to execute like so:

./myprogram --someArg 2 --thisFails - --anotherArg 3

Where the value of thisFails should be set to -

I've also tried: "-" to no avail

The error I'm getting is:

ERROR(S):
  Option 'thisFails' has no value.

Activity

  1. moh-hassan commented on Feb 1, 2020

    @moh-hassan
    Collaborator

    Use triple quote to quote "-" in the commandline, , then it will passed to the parser with Single Quote:

    --somearg 2 --thisfails """-""" --anotherarg 3

  2. tevoinea commented on Feb 5, 2020

    @tevoinea
    Author

    In my testing, the triple quote returned a value of "-" not - but that's ok, we can work around that.

    Thanks!

  3. moh-hassan commented on Jul 5, 2020

    @moh-hassan
    Collaborator

    To avoid tripple quote, merging options with single dash as a value is allowed:

    ./myprogram --someArg 2 --thisSuccess=- --anotherArg 3  #merge longname with dash using '=' e.g `--thisSuccess=-`
    ./myprogram --someArg 2   -s- --anotherArg 3  #merge shortname with dash: `-s-`
    
  4. moh-hassan commented on Jul 24, 2020

    @moh-hassan
    Collaborator

    Single dash will be considered as a value in the next release

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions