INNER CODE UNIT · Python
parse_args
Yelp/paasta · paasta_tools/cli/cli.py:217
def parse_args(argv):
"""Initialize autocompletion and configure the argument parser.
:return: an argparse.Namespace object mapping parameter names to the inputs
from sys.argv
"""
# NOTE: in "real" use, these env vars are set by
# paasta_tabcomplete.sh (which we plop into
# usr/share/bash-completion/completions/ as our completion script)
if "_ARGCOMPLETE" in os.environ:
# NOTE: COMP_LINE will be the full command so far
comp_line = os.environ.get("COMP_LINE", "")
comp_words = comp_line.split()
# ...but we want to grab the subcommand since the
# shell can handle tab-completing `paasta` :p
if len(comp_words) >= 2 and comp_words[1] in PAASTA_SUBCOMMANDS:
parser = get_argparser(commands=[comp_words[1]])