├── docopt ├── py.typed ├── _version.py └── __init__.py ├── CONTRIBUTING.md ├── examples ├── odd_even_example.py ├── quick_example.py ├── counted_example.py ├── calculator_example.py ├── options_shortcut_example.py ├── naval_fate.py ├── arguments_example.py ├── git │ ├── git_remote.py │ ├── git_add.py │ ├── git_push.py │ ├── git_checkout.py │ ├── git_clone.py │ ├── git_branch.py │ ├── git.py │ └── git_commit.py ├── validation_example.py ├── options_example.py ├── interactive_example.py └── config_file_example.py ├── .gitignore ├── LICENSE-MIT ├── pyproject.toml ├── .pre-commit-config.yaml ├── .github └── workflows │ └── test.yml ├── CODE_OF_CONDUCT.md ├── tests ├── test_docopt_ng.py ├── conftest.py ├── testcases.docopt └── test_docopt.py ├── CHANGELOG.md ├── README.md └── pdm.lock /docopt/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docopt/_version.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.9.0" 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | [![Jazzband](https://jazzband.co/static/img/jazzband.svg)](https://jazzband.co/) 2 | 3 | This is a [Jazzband](https://jazzband.co/) project. By contributing you agree to abide by the [Contributor Code of Conduct](https://jazzband.co/about/conduct) and follow the [guidelines](https://jazzband.co/about/guidelines). 4 | -------------------------------------------------------------------------------- /examples/odd_even_example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Usage: odd_even_example.py [-h | --help] (ODD EVEN)... 3 | 4 | Example, try: 5 | odd_even_example.py 1 2 3 4 6 | 7 | Options: 8 | -h, --help 9 | """ 10 | 11 | from docopt import docopt 12 | 13 | if __name__ == "__main__": 14 | arguments = docopt(__doc__) 15 | print(arguments) 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !.github 3 | !.gitignore 4 | 5 | *.py[co] 6 | 7 | # Vim 8 | *.swp 9 | 10 | # Packages 11 | *.egg 12 | *.egg-info 13 | dist 14 | build 15 | eggs 16 | parts 17 | bin 18 | var 19 | sdist 20 | develop-eggs 21 | .installed.cfg 22 | 23 | # Installer logs 24 | pip-log.txt 25 | 26 | # Unit test / coverage reports 27 | .coverage 28 | coverage.xml 29 | .pdm-python 30 | -------------------------------------------------------------------------------- /examples/quick_example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Usage: 4 | quick_example.py tcp [--timeout=] 5 | quick_example.py serial [--baud=9600] [--timeout=] 6 | quick_example.py -h | --help | --version 7 | """ 8 | 9 | from docopt import docopt 10 | 11 | if __name__ == "__main__": 12 | arguments = docopt(__doc__, version="0.1.1rc") 13 | print(arguments) 14 | -------------------------------------------------------------------------------- /examples/counted_example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Usage: counted_example.py --help 3 | counted_example.py -v... 4 | counted_example.py go [go] 5 | counted_example.py (--path=)... 6 | counted_example.py 7 | 8 | Try: counted_example.py -vvvvvvvvvv 9 | counted_example.py go go 10 | counted_example.py --path ./here --path ./there 11 | counted_example.py this.txt that.txt 12 | """ 13 | 14 | from docopt import docopt 15 | 16 | print(docopt(__doc__)) 17 | -------------------------------------------------------------------------------- /examples/calculator_example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Not a serious example. 3 | 4 | Usage: 5 | calculator_example.py ( ( + | - | * | / ) )... 6 | calculator_example.py [( , )]... 7 | calculator_example.py (-h | --help) 8 | 9 | Examples: 10 | calculator_example.py 1 + 2 + 3 + 4 + 5 11 | calculator_example.py 1 + 2 '*' 3 / 4 - 5 # note quotes around '*' 12 | calculator_example.py sum 10 , 20 , 30 , 40 13 | 14 | Options: 15 | -h, --help 16 | """ 17 | 18 | from docopt import docopt 19 | 20 | if __name__ == "__main__": 21 | arguments = docopt(__doc__) 22 | print(arguments) 23 | -------------------------------------------------------------------------------- /examples/options_shortcut_example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Example of program which uses [options] shortcut in pattern. 3 | 4 | Usage: 5 | options_shortcut_example.py [options] 6 | 7 | Options: 8 | -h --help show this help message and exit 9 | --version show version and exit 10 | -n, --number N use N as a number 11 | -t, --timeout TIMEOUT set timeout TIMEOUT seconds 12 | --apply apply changes to database 13 | -q operate in quiet mode 14 | """ 15 | 16 | from docopt import docopt 17 | 18 | if __name__ == "__main__": 19 | arguments = docopt(__doc__, version="1.0.0rc2") 20 | print(arguments) 21 | -------------------------------------------------------------------------------- /examples/naval_fate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Naval Fate. 3 | 4 | Usage: 5 | naval_fate.py ship new ... 6 | naval_fate.py ship move [--speed=] 7 | naval_fate.py ship shoot 8 | naval_fate.py mine (set|remove) [--moored|--drifting] 9 | naval_fate.py -h | --help 10 | naval_fate.py --version 11 | 12 | Options: 13 | -h --help Show this screen. 14 | --version Show version. 15 | --speed= Speed in knots [default: 10]. 16 | --moored Moored (anchored) mine. 17 | --drifting Drifting mine. 18 | """ 19 | 20 | from docopt import docopt 21 | 22 | if __name__ == "__main__": 23 | arguments = docopt(__doc__, version="Naval Fate 2.0") 24 | print(arguments) 25 | -------------------------------------------------------------------------------- /examples/arguments_example.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Usage: arguments_example.py [-vqrh] [FILE] ... 3 | arguments_example.py (--left | --right) CORRECTION FILE 4 | 5 | Process FILE and optionally apply correction to either left-hand side or 6 | right-hand side. 7 | 8 | Arguments: 9 | FILE optional input file 10 | CORRECTION correction angle, needs FILE, --left or --right to be present 11 | 12 | Options: 13 | -h --help 14 | -v verbose mode 15 | -q quiet mode 16 | -r make report 17 | --left use left-hand side 18 | --right use right-hand side 19 | """ 20 | 21 | from docopt import docopt 22 | 23 | if __name__ == "__main__": 24 | arguments = docopt(__doc__) 25 | print(arguments) 26 | -------------------------------------------------------------------------------- /examples/git/git_remote.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | usage: git remote [-v | --verbose] 4 | git remote add [-t ] [-m ] [-f] [--mirror] 5 | git remote rename 6 | git remote rm 7 | git remote set-head (-a | -d | ) 8 | git remote [-v | --verbose] show [-n] 9 | git remote prune [-n | --dry-run] 10 | git remote [-v | --verbose] update [-p | --prune] [( | )...] 11 | git remote set-branches [--add] ... 12 | git remote set-url [] 13 | git remote set-url --add 14 | git remote set-url --delete 15 | 16 | -v, --verbose be verbose; must be placed before a subcommand 17 | """ 18 | 19 | from docopt import docopt 20 | 21 | if __name__ == "__main__": 22 | arguments = docopt(__doc__) 23 | print(arguments) 24 | -------------------------------------------------------------------------------- /examples/git/git_add.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | usage: git add [options] [--] [...] 4 | 5 | -h, --help 6 | -n, --dry-run dry run 7 | -v, --verbose be verbose 8 | 9 | -i, --interactive interactive picking 10 | -p, --patch select hunks interactively 11 | -e, --edit edit current diff and apply 12 | -f, --force allow adding otherwise ignored files 13 | -u, --update update tracked files 14 | -N, --intent-to-add record only the fact that the path will be added later 15 | -A, --all add all, noticing removal of tracked files 16 | --refresh don't add, only refresh the index 17 | --ignore-errors just skip files which cannot be added because of errors 18 | --ignore-missing check if - even missing - files are ignored in dry run 19 | """ 20 | 21 | from docopt import docopt 22 | 23 | if __name__ == "__main__": 24 | print(docopt(__doc__)) 25 | -------------------------------------------------------------------------------- /examples/git/git_push.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | usage: git push [options] [ [...]] 4 | 5 | -h, --help 6 | -v, --verbose be more verbose 7 | -q, --quiet be more quiet 8 | --repo repository 9 | --all push all refs 10 | --mirror mirror all refs 11 | --delete delete refs 12 | --tags push tags (can't be used with --all or --mirror) 13 | -n, --dry-run dry run 14 | --porcelain machine-readable output 15 | -f, --force force updates 16 | --thin use thin pack 17 | --receive-pack 18 | receive pack program 19 | --exec 20 | receive pack program 21 | -u, --set-upstream set upstream for git pull/status 22 | --progress force progress reporting 23 | """ 24 | 25 | from docopt import docopt 26 | 27 | if __name__ == "__main__": 28 | print(docopt(__doc__)) 29 | -------------------------------------------------------------------------------- /examples/git/git_checkout.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | usage: git checkout [options] 4 | git checkout [options] -- ... 5 | 6 | -q, --quiet suppress progress reporting 7 | -b create and checkout a new branch 8 | -B create/reset and checkout a branch 9 | -l create reflog for new branch 10 | -t, --track set upstream info for new branch 11 | --orphan 12 | new unparented branch 13 | -2, --ours checkout our version for unmerged files 14 | -3, --theirs checkout their version for unmerged files 15 | -f, --force force checkout (throw away local modifications) 16 | -m, --merge perform a 3-way merge with the new branch 17 | --conflict