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

Conflicting arguments in group only work for first group in YAML file #2409

Closed
2 tasks done
DocKDE opened this issue Mar 12, 2021 · 6 comments
Closed
2 tasks done

Conflicting arguments in group only work for first group in YAML file #2409

DocKDE opened this issue Mar 12, 2021 · 6 comments
Labels
C-bug Category: Updating dependencies 💸 $5

Comments

@DocKDE
Copy link

DocKDE commented Mar 12, 2021

Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

Rust Version

1.50.0

Clap Version

3.0.0-beta.2

Minimal reproducible code

name: pdbman
version: "0.1"
author: Me
about: Does stuff

settings: [DeriveDisplayOrder, ArgRequiredElseHelp, ColoredHelp, ColorAlways]
    # - UnifiedHelpMessage
    # - DeriveDisplayOrder

args:
    - INPUT:
        about: Name of PDB file
        required: true
    - Query:
        about: Query mode
        long: query
        short: Q
    - Analyze:
        about: Analysis mode
        long: analyze
        short: Y
    - Add:
        about: Add mode
        long: add
        short: A
    - Remove:
        about: Remove mode
        long: remove
        short: R
    - Residues:
        about: Residue mode
        long: residues
        short: r
    - Atoms:
        about: Atom mode
        long: atoms
        short: t
    - Sidechain:
        about: Use only sidechains of protein
        long: sidechain
        short: d
        requires:
            - Residues
    - Backbone:
        about: Use only backbones of protein
        long: backbone
        short: b
        requires:
            - Residues
    - QM1:
        about: QM1 region
        long: qm1
        short: q
    - QM2:
        about: QM1 region
        long: qm2
        short: o
    - Active:
        about: Active revion
        long: active
        short: a
    - Infile:
        about: File for list input
        long: file
        short: f
        takes_value: true
    - List:
        about: Command line list
        long: list
        short: l
        takes_value: true
        multiple: true
        use_delimiter: true
    - Sphere:
        about: Calculate sphere around atom. Requires Atom ID and radius in A as arguments.
        long: sphere
        short: s
        takes_value: true
        min_values: 2
        max_values: 2
        conflicts_with:
            - Sidechain
            - Backbone
    - Outfile:
        about: Name of PDB output file
        long: outfile
        short: e
        takes_value: true
    - Overwrite:
        about: Overwrite input PDB file
        long: overwrite
        short: w
  
groups:
    - mode:
        args: [Query, Analyze, Add, Remove]
        required: true
    - partial:
        args: [Sidechain, Backbone]
    - target:
        args: [Atoms, Residues]
    - region:
        args: [QM1, QM2, Active]
    - source:
        args: [File, List, Sphere]
    - output:
        args: [Outfile, Overwrite]

Steps to reproduce the bug with the above code

Use this .yaml for any command line parsing.

Actual Behaviour

When calling the binary like pdbman -QY it fails with error: The argument '--query' cannot be used with '--analyze'. However the same is not true if I call multiple arguments from other groups like so: pdbman -Aqo or pdbman -Qrt. These commands run without error. It appears that only the args from the topmost group in the YAML file are recognized as being mutally exclusive. I verified this by changing their order.

Expected Behaviour

I would expect a command calling arguments from the same group to also fail with this: error: The argument '--residues' cannot be used with '--atoms' if they belong to the same group.

Additional Context

No response

Debug Output

No response

@DocKDE DocKDE added the C-bug Category: Updating dependencies label Mar 12, 2021
@pksunkara
Copy link
Member

Need the command which is failing and the debug output.

@pksunkara pksunkara reopened this Mar 12, 2021
@pksunkara
Copy link
Member

Basically, the "actual behaviour" sections need actual command runs and their outputs.

@DocKDE
Copy link
Author

DocKDE commented Mar 12, 2021

I updated the section for expected and actual behaviour. Although I must add I'm not sure what you mean by failing commands and debug output. My issue is precisely that there is no failing command when I expected it so there's no debug output I can post.

@pksunkara
Copy link
Member

What you wrote now is good.

@pksunkara
Copy link
Member

@DocKDE Can you please try with the latest master now?

@epage
Copy link
Member

epage commented Dec 8, 2021

We have decided to deprecate the YAML API. For more details, see #3087. If there is interest in a YAML API, it will likely be broken out into a clap_yaml and developed independent from the core of clap.

@epage epage closed this as completed Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Updating dependencies 💸 $5
Projects
None yet
Development

No branches or pull requests

3 participants