The project is in a healthy, maintained state
docopt completion generator
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13.0

Runtime

~> 0.8.1
~> 0.6.1
 Project Readme

docopt-compgen

docopt-compgen is a program that parses docopt help text and generates shell completions for it.

It uses docopt itself to do the parsing and generates the completions directly from docopt's internal representation.

The only supported shell at the moment is Bash.

Installation

Install from rubygems.org.

gem install docopt-compgen

The binary is called docopt-compgen.

Usage

Usage:
    docopt-compgen [options] [<command>]

Options:
    -o, --out PATH         Output completion to PATH instead of stdout
    --complete-short       Complete short options (long options are always completed)
    --command-name NAME    Command name
                           If not specified then the slugified basename of <command> will be used
    --namespace NAME       Prefix for generated bash functions [default: cmd]
    --header TEXT          Header to insert at the start of the completion script
    -v, --version          Show version

Examples

Pass a command name to run

If a command name is passed as an argument then it will be run with --help and the result will be used as help text.

docopt-compgen example

Pass in help text via stdin

Input can also be passed in via stdin.

echo -e "Usage:\n    example --flag" | docopt-compgen

The name of the command will be extracted from the help text but can be overridden with --command-name if desired.

Contributions

Open an issue or send a pull request.

Licence

GPLv3.