Exemplo n.º 1
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    import argparse
    parser = ConfigBackedParser(
        'git-nbdifftool',
        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_filter_args(diff_parser)
    nbdifftool.build_arg_parser(diff_parser)
    diff_parser.add_argument('path', type=Path)

    config = add_git_config_subcommand(
        subparsers,
        enable,
        disable,
        subparser_help="Configure git to use nbdime via `git difftool`",
        enable_help="enable nbdime difftool via git config",
        disable_help="disable nbdime difftool via git config")
    config.add_argument('--set-default',
                        action='store_true',
                        dest='set_default',
                        help="set nbdime as default gui difftool")

    opts = parser.parse_args(args)
    if opts.subcommand == 'diff':
        remote = opts.remote
        if opts.use_filter and remote:
            remote = apply_possible_filter(opts.path, remote)
        return show_diff(opts.local, remote, opts)
    elif opts.subcommand == 'config':
        opts.config_func(opts.scope, opts.set_default)
        return 0
    else:
        parser.print_help()
        return 1
Exemplo n.º 2
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    import argparse
    parser = ConfigBackedParser('hg-nbdiffweb', description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )

    nbdifftool.build_arg_parser(parser)
    opts = parser.parse_args(args)

    # TODO: If a/b are files that are not notebooks, ensure a decent error is printed.
    if not os.path.isfile(opts.local) or not os.path.isfile(opts.remote):
        local, remote = opts.local, opts.remote
        for a, b in diff_directories(local, remote):
            opts.local, opts.remote = a, b
            ret = nbdifftool.main_parsed(opts)
            if ret != 0:
                return ret
        return ret
    else:
        return nbdifftool.main_parsed(opts)
Exemplo n.º 3
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    import argparse
    parser = ConfigBackedParser('git-nbdifftool', 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_filter_args(diff_parser)
    nbdifftool.build_arg_parser(diff_parser)
    diff_parser.add_argument('path')

    config = add_git_config_subcommand(subparsers,
        enable, disable,
        subparser_help="Configure git to use nbdime via `git difftool`",
        enable_help="enable nbdime difftool via git config",
        disable_help="disable nbdime difftool via git config")
    config.add_argument('--set-default', action='store_true', dest='set_default',
        help="set nbdime as default gui difftool"
    )

    opts = parser.parse_args(args)
    if opts.subcommand == 'diff':
        remote = opts.remote
        if opts.use_filter and remote:
            remote = apply_possible_filter(opts.path, remote)
        return show_diff(opts.local, remote, opts)
    elif opts.subcommand == 'config':
        opts.config_func(opts.scope, opts.set_default)
        return 0
    else:
        parser.print_help()
        return 1