Skip to content

docopt_completion doesn't seem to honor mandatory arguments #9

@con-f-use

Description

@con-f-use

The module does not seem to fully honor mandatory backets (-option) and ignores commands therein.

Example code:

#!/usr/bin/env python
"""Demonstration of docopt_completion not honoring exclusives.

Usage:
    exhon.py --help
    exhon.py (-c cmd)

Options:
  -h      Print help
  -c     Indicats command mode
"""
from docopt import docopt
arguments = docopt(__doc__)
print arguments

Expected behavior in bash session:

confus@confusion:~/test$ exhon.py #[TAB]
-c         --help
confus@confusion:~/test$ exhon.py -c #[TAB] completes to only allowed commad:
confus@confusion:~/test$ exhon.py -c cmd

Actual (wrong) behavior in bash session:

confus@confusion:~/test$ exhon.py #[TAB] gives wrong selection ("cmd" should not be there)
-c         cmd    --help
confus@confusion:~/test$ exhon.py -c #[TAB] gives no completion (should complete to "... -c cmd")
confus@confusion:~/test$ exhon.py -c

Arranging the usage string the other way around as in exhon.py (cmd -c) yields better but similarly wrong results:

confus@confusion:~/test$ exhon.py cmd#[TAB] completes as expected to:
confus@confusion:~/test$ exhon.py cmd -c#[TAB] but further tab repeats the option:
confus@confusion:~/test$ exhon.py cmd -c -c # again and again if [TAB] is pressed more often

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