Skip to content

Group dependent flags #344

@esclear

Description

@esclear

Hello, I'd like to use docopt for rather complicated flags.

For a package manager I'd like to provide an interface that follows the following EBNF:

flags ::= ( '--git' 'URL' ( '--branch' 'BRANCH' | '--tag' 'TAG' | '--rev' 'REV' )? | '--path' 'PATH' | 'CRATE' ( '--vers' 'VERSION' )? )+

flags

I tried to achieve this with the following docopt pattern:

Usage:
  prog (--git=URL [--branch=BRANCH | --tag=TAG | --rev=REV] | --path=PATH | CRATE [--version=VERSION])...

Executing this with the parameters crate1 --version=foo crate2 --git url1 --tag release --git url2 --branch develop yields the following:

{"--branch": ["develop"],
 "--git": ["url1","'url2"],
 "--path": [],
 "--rev": [],
 "--tag": ["release"],
 "--version": ["foo"],
 "CRATE": ["crate1", "crate2"]}

My problem is that I want to keep the branch, tag or rev flag together with the giturl as well as the version together with crate.
Otherwise I don't know which tag belongs to which giturl and which version to which crate.

Can someone give me a heads up on this one?
Thank you in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions