def main(args=None): if args is None: args = sys.argv[1:] parser = ConfigBackedParser( "git-pjmergedriver", description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, ) subparsers = parser.add_subparsers(dest="subcommand") merge_parser = subparsers.add_parser( "merge", description= "The actual entrypoint for the merge tool. Git will call this.", ) add_generic_args(parser) add_diff_args(merge_parser) add_merge_args(merge_parser) # Argument list, we are given base, local, remote add_filename_args(merge_parser, ["base", "local", "remote"]) # TODO: support git-config-specified conflict markers inside sources merge_parser.add_argument("marker") merge_parser.add_argument("out", nargs="?") # "The merge driver can learn the pathname in which the merged result will # be stored via placeholder %P" # - NOTE: This is not where the driver should store its output, see below! add_git_config_subcommand( subparsers, enable, disable, subparser_help= "Configure git to use packson for notebooks in `git merge`", enable_help="enable packson merge driver via git config", disable_help="disable packson merge driver via git config", ) opts = parser.parse_args(args) if opts.subcommand == "merge": # "The merge driver is expected to leave the result of the merge in the # file named with %A by overwriting it, and exit with zero status if it # managed to merge them cleanly, or non-zero if there were conflicts." opts.out = opts.local # mergeapp expects an additional decisions arg: opts.decisions = False return main_merge(opts) elif opts.subcommand == "config": opts.config_func(opts.scope) return 0 else: parser.print_help() return 1
def main(args=None): if args is None: args = sys.argv[1:] parser = ConfigBackedParser('git-nbmergedriver', description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, ) subparsers = parser.add_subparsers(dest='subcommand') merge_parser = subparsers.add_parser('merge', description="The actual entrypoint for the merge tool. Git will call this." ) add_generic_args(parser) add_diff_args(merge_parser) add_merge_args(merge_parser) # Argument list, we are given base, local, remote add_filename_args(merge_parser, ["base", "local", "remote"]) # TODO: support git-config-specified conflict markers inside sources merge_parser.add_argument('marker') merge_parser.add_argument('out', nargs='?') # "The merge driver can learn the pathname in which the merged result will # be stored via placeholder %P" # - NOTE: This is not where the driver should store its output, see below! add_git_config_subcommand( subparsers, enable, disable, subparser_help="Configure git to use nbdime for notebooks in `git merge`", enable_help="enable nbdime merge driver via git config", disable_help="disable nbdime merge driver via git config") opts = parser.parse_args(args) if opts.subcommand == 'merge': # "The merge driver is expected to leave the result of the merge in the # file named with %A by overwriting it, and exit with zero status if it # managed to merge them cleanly, or non-zero if there were conflicts." opts.out = opts.local # mergeapp expects an additional decisions arg: opts.decisions = False return nbmergeapp.main_merge(opts) elif opts.subcommand == 'config': opts.config_func(opts.scope) return 0 else: parser.print_help() return 1
def main(args=None): if args is None: args = sys.argv[1:] import argparse parser = ConfigBackedParser('git-nbmergetool', description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, ) add_generic_args(parser) subparsers = parser.add_subparsers(dest='subcommand') merge_parser = subparsers.add_parser('merge', description="The actual entrypoint for the mergetool. Git will call this." ) nbmergetool.build_arg_parser(merge_parser) config = add_git_config_subcommand(subparsers, enable, disable, subparser_help="Configure git to use nbdime via `git mergetool`", enable_help="enable nbdime mergetool via git config", disable_help="disable nbdime mergetool via git config") config.add_argument('--set-default', action='store_true', dest='set_default', help="set nbdime as default mergetool" ) opts = parser.parse_args(args) if opts.subcommand == 'merge': return nbmergetool.main_parsed(opts) elif opts.subcommand == 'config': opts.config_func(opts.scope, opts.set_default) return 0 else: parser.print_help() return 1
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
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
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
def main(args=None): if args is None: args = sys.argv[1:] import argparse parser = ConfigBackedParser( 'git-nbmergetool', description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, ) add_generic_args(parser) subparsers = parser.add_subparsers(dest='subcommand') merge_parser = subparsers.add_parser( 'merge', description= "The actual entrypoint for the mergetool. Git will call this.") nbmergetool.build_arg_parser(merge_parser) config = add_git_config_subcommand( subparsers, enable, disable, subparser_help="Configure git to use nbdime via `git mergetool`", enable_help="enable nbdime mergetool via git config", disable_help="disable nbdime mergetool via git config") config.add_argument('--set-default', action='store_true', dest='set_default', help="set nbdime as default mergetool") opts = parser.parse_args(args) if opts.subcommand == 'merge': return nbmergetool.main_parsed(opts) elif opts.subcommand == 'config': opts.config_func(opts.scope, opts.set_default) return 0 else: parser.print_help() return 1
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