Beispiel #1
0
def _build_arg_parser():
    """Creates an argument parser for the nbdiff command."""
    parser = ConfigBackedParser(
        description=_description,
        )
    add_generic_args(parser)
    add_diff_args(parser)
    add_diff_cli_args(parser)

    parser.add_argument(
        "base", help="the base notebook filename OR base git-revision.",
        nargs='?', default='HEAD',
    )
    parser.add_argument(
        "remote", help="the remote modified notebook filename OR remote git-revision.",
        nargs='?', default=None,
    )
    parser.add_argument(
        "paths", help="filter diffs for git-revisions based on path",
        nargs='*', default=None,
    )

    parser.add_argument(
        '--out',
        default=None,
        help="if supplied, the diff is written to this file. "
             "Otherwise it is printed to the terminal.")

    return parser
Beispiel #2
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    import argparse
    parser = ConfigBackedParser(
        'hg-nbdiff',
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )

    add_diff_args(parser)
    add_diff_cli_args(parser)
    add_prettyprint_args(parser)
    add_filename_args(parser, ('base', 'remote'))

    opts = parser.parse_args(args)

    # TODO: Filter base/remote: If directories, find all modified notebooks
    # If files that are not notebooks, ensure a decent error is printed.
    if not os.path.isfile(opts.base) or not os.path.isfile(opts.remote):
        base, remote = opts.base, opts.remote
        for a, b in diff_directories(base, remote):
            opts.base, opts.remote = a, b
            ret = nbdiffapp.main_diff(opts)
            if ret != 0:
                return ret
        return ret
    else:
        return nbdiffapp.main_diff(opts)
Beispiel #3
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    import argparse
    parser = ConfigBackedParser('hg-nbdiff', description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )

    add_diff_args(parser)
    add_diff_cli_args(parser)
    add_filename_args(parser, ('base', 'remote'))

    opts = parser.parse_args(args)

    # TODO: Filter base/remote: If directories, find all modified notebooks
    # If files that are not notebooks, ensure a decent error is printed.
    if not os.path.isfile(opts.base) or not os.path.isfile(opts.remote):
        base, remote = opts.base, opts.remote
        for a, b in diff_directories(base, remote):
            opts.base, opts.remote = a, b
            ret = nbdiffapp.main_diff(opts)
            if ret != 0:
                return ret
        return ret
    else:
        return nbdiffapp.main_diff(opts)
Beispiel #4
0
def _build_arg_parser():
    """Creates an argument parser for the nbdiff command."""
    parser = ConfigBackedParser(
        description=_description,
        )
    add_generic_args(parser)
    add_diff_args(parser)
    add_diff_cli_args(parser)

    parser.add_argument(
        "base", help="the base notebook filename OR base git-revision.",
        nargs='?', default='HEAD',
    )
    parser.add_argument(
        "remote", help="the remote modified notebook filename OR remote git-revision.",
        nargs='?', default=None,
    )
    parser.add_argument(
        "paths", help="filter diffs for git-revisions based on path",
        nargs='*', default=None,
    )

    parser.add_argument(
        '--out',
        default=None,
        help="if supplied, the diff is written to this file. "
             "Otherwise it is printed to the terminal.")

    return parser
Beispiel #5
0
def _build_arg_parser():
    import argparse
    parser = argparse.ArgumentParser('git-nbdiffdriver',
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    add_generic_args(parser)

    subparsers = parser.add_subparsers(dest='subcommand')

    diff_parser = subparsers.add_parser('diff',
        description="The actual entrypoint for the diff tool. Git will call this."
    )
    add_git_diff_driver_args(diff_parser)
    add_diff_args(diff_parser)
    add_diff_cli_args(diff_parser)

    webdiff_parser = subparsers.add_parser('webdiff',
        description="The actual entrypoint for the webdiff tool. Git will call this."
    )
    add_git_diff_driver_args(webdiff_parser)
    add_diff_args(webdiff_parser)
    add_web_args(webdiff_parser, 0)

    # TODO: From git docs: "For a path that is unmerged, GIT_EXTERNAL_DIFF is called with 1 parameter, <path>."
    config = add_git_config_subcommand(subparsers,
        enable, disable,
        subparser_help="Configure git to use nbdime for notebooks in `git diff`",
        enable_help="enable nbdime diff driver via git config",
        disable_help="disable nbdime diff driver via git config")

    return parser
Beispiel #6
0
def _build_arg_parser():
    import argparse
    parser = ConfigBackedParser('git-nbdiffdriver',
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    add_generic_args(parser)

    subparsers = parser.add_subparsers(dest='subcommand')

    diff_parser = subparsers.add_parser('diff',
        description="The actual entrypoint for the diff tool. Git will call this."
    )
    add_git_diff_driver_args(diff_parser)
    add_diff_args(diff_parser)
    add_diff_cli_args(diff_parser)

    webdiff_parser = subparsers.add_parser('webdiff',
        description="The actual entrypoint for the webdiff tool. Git will call this."
    )
    add_git_diff_driver_args(webdiff_parser)
    add_diff_args(webdiff_parser)
    add_web_args(webdiff_parser, 0)

    # TODO: From git docs: "For a path that is unmerged, GIT_EXTERNAL_DIFF is called with 1 parameter, <path>."
    config = add_git_config_subcommand(subparsers,
        enable, disable,
        subparser_help="Configure git to use nbdime for notebooks in `git diff`",
        enable_help="enable nbdime diff driver via git config",
        disable_help="disable nbdime diff driver via git config")

    return parser