Command line parser for jupytext

def parse_jupytext_args(args=None):
    """Command line parser for jupytext"""
    parser = argparse.ArgumentParser(
        description='Jupyter notebooks as markdown documents, Julia, Python or R scripts',
        formatter_class=argparse.RawTextHelpFormatter)

    # Input
    parser.add_argument('notebooks',
                        help='One or more notebook(s). Notebook is read from stdin when this argument is empty',
                        nargs='*')
    parser.add_argument('--from',
                        dest='input_format',
                        help='Optional: jupytext format for the input(s). '
                             'Inferred from the file extension and content when missing.')
    parser.add_argument('--pre-commit',
                        action='store_true',
                        help='Ignore the notebook argument, and instead apply Jupytext on the notebooks found '
                             'in the git index, which have an extension that matches the (optional) --from argument.')
    # Destination format & act on metadata
    parser.add_argument('--to',
                        help="Destination format: either one of 'notebook', 'markdown', 'rmarkdown', any valid "
                             "notebook extension, or a full format '[prefix_path//][suffix.]ext[:format_name]")
    parser.add_argument('--format-options', '--opt',
                        action='append',
                        help='Set format options with e.g. --opt comment_magics=true '
                             '--opt notebook_metadata_filter=-kernelspec.')
    parser.add_argument('--set-formats',
                        type=str,
                        help='Set jupytext.formats metadata to the given value. Use this to activate pairing on a '
                             'notebook, with e.g. --set-formats ipynb,py:light')
    parser.add_argument('--update-metadata',
                        default={},
                        type=json.loads,
                        help='Update the notebook metadata with the desired dictionary. Argument must be given in JSON '
                             'format. For instance, if you want to activate a pairing in the generated file, '
                             """use e.g. '{"jupytext":{"formats":"ipynb,py:light"}}'""")

    # Destination file
    parser.add_argument('-o', '--output',
                        help="Destination file. Defaults to the original file, with prefix/suffix/extension changed"
                             "according to the destination format. Use '-' to print the notebook on stdout.")
    parser.add_argument('--update', action='store_true',
                        help='Preserve the output cells when the destination notebook is a .ipynb file '
                             'that already exists')

    # Action: convert(default)/version/list paired paths/sync/apply/test
    action = parser.add_mutually_exclusive_group()
    action.add_argument('--version',
                        action='store_true',
                        help="Show jupytext's version number and exit")
    action.add_argument('--paired-paths', '-p',
                        help='List the locations of the alternative representations for this notebook.',
                        action='store_true')
    action.add_argument('--sync', '-s',
                        help='Synchronize the content of the paired representations of the given notebook. '
                             'Input cells are taken from the file that was last modified, and outputs are read '
                             'from the ipynb file, if present.',
                        action='store_true')
    action.add_argument('--test',
                        action='store_true',
                        help='Test that notebook is stable under a round trip conversion, up to the expected changes')
    action.add_argument('--test-strict',
                        action='store_true',
                        help='Test that notebook is strictly stable under a round trip conversion')
    parser.add_argument('--stop', '-x',
                        dest='stop_on_first_error',
                        action='store_true',
                        help='In --test mode, stop on first round trip conversion error, and report stack traceback')

    # Pipe notebook inputs into other commands
    parser.add_argument('--pipe',
                        action='append',
                        help='Pipe the text representation of the notebook into another program, and read the'
                             'notebook back. For instance, reformat your notebook with:'
                             "    jupytext notebook.ipynb --pipe black"
                             'If you want to reformat it and sync the paired representation, execute:'
                             "    jupytext notebook.ipynb --sync --pipe black")
    parser.add_argument('--check',
                        action='append',
                        help='Pipe the text representation of the notebook into another program, and test that '
                             'the returned value is non zero. For instance, test that your notebook is pep8 compliant '
                             'with:'
                             "    jupytext notebook.ipynb --check flake8")
    parser.add_argument('--pipe-fmt',
                        default='auto:percent',
                        help='The format in which the notebook should be piped to other programs, when using the '
                             '--pipe and/or --check commands.')

    parser.add_argument('--quiet', '-q',
                        action='store_true',
                        default=False,
                        help='Quiet mode: do not comment about files being updated or created')

    return parser.parse_args(args)