def _build_arg_parser(): """Creates an argument parser for the nbshow command.""" parser = argparse.ArgumentParser( description=_description, add_help=True, ) add_generic_args(parser) parser.add_argument("notebook", nargs="*", help="notebook filename(s) or - to read from stdin") # Things we can choose to show or not parser.add_argument('-s', '--sources', action=IgnorableAction, help="show sources.") parser.add_argument('-o', '--outputs', action=IgnorableAction, help="show outputs.") parser.add_argument('-a', '--attachments', action=IgnorableAction, help="show attachments.") parser.add_argument('-m', '--metadata', action=IgnorableAction, help="show metadata.") parser.add_argument('-d', '--details', action=IgnorableAction, help="show details not covered by other options.") return parser
def _build_arg_parser(): """Creates an argument parser for the nbshow command.""" parser = ConfigBackedParser( description=_description, add_help=True, ) add_generic_args(parser) parser.add_argument("notebook", nargs="*", help="notebook filename(s) or - to read from stdin") # Things we can choose to show or not ignorables = parser.add_argument_group( title='ignorables', description='Set which parts of the notebook (not) to show.') ignorables.add_argument( '-s', '--sources', action=IgnorableAction, help="show/ignore sources.") ignorables.add_argument( '-o', '--outputs', action=IgnorableAction, help="show/ignore outputs.") ignorables.add_argument( '-a', '--attachments', action=IgnorableAction, help="show/ignore attachments.") ignorables.add_argument( '-m', '--metadata', action=IgnorableAction, help="show/ignore metadata.") ignorables.add_argument( '-d', '--details', action=IgnorableAction, help="show/ignore details not covered by other options.") 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 _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(): """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
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(): """ Creates an argument parser that lets the user specify a port and displays a help message. """ description = 'Web interface for Nbdime.' parser = ArgumentParser(description=description) add_generic_args(parser) add_web_args(parser) return parser
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 _build_arg_parser(): """ Creates an argument parser """ description = 'Web interface for Nbdime.' parser = ArgumentParser(description=description) add_generic_args(parser) add_web_args(parser) parser.add_argument('--ip', default='0.0.0.0', help='Which IP/name to have the server listen on.') return parser
def _build_arg_parser(): """Creates an argument parser for the nbdiff command.""" parser = argparse.ArgumentParser(description=_description, add_help=True) add_generic_args(parser) add_diff_args(parser) add_filename_args(parser, ["base", "remote"]) parser.add_argument( "-o", "--output", default=None, help="if supplied, the diff is written to this file. " "Otherwise it is printed to the terminal.", ) return parser
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 _build_arg_parser(): """Creates an argument parser for the nbdiff command.""" parser = argparse.ArgumentParser( description=_description, add_help=True, ) add_generic_args(parser) add_diff_args(parser) add_filename_args(parser, ["base", "remote"]) 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
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 _build_arg_parser(): """Creates an argument parser for the nbdiff command.""" parser = ConfigBackedParser(description=_description, add_help=True) from nbdime.args import ( add_generic_args, add_diff_args, add_merge_args, filename_help, add_filename_args, add_prettyprint_args, ) add_generic_args(parser) add_diff_args(parser) add_merge_args(parser) add_prettyprint_args(parser) parser.add_argument( "base", type=Path, help=filename_help["base"], nargs="?", default=EXPLICIT_MISSING_FILE, ) add_filename_args(parser, ["local", "remote"]) parser.add_argument( "--out", default=None, type=Path, help="if supplied, the merged notebook is written " "to this file. Otherwise it is printed to the " "terminal.", ) parser.add_argument( "--decisions", action="store_true", help="print a human-readable summary of conflicted " "merge decisions instead of merging the notebook.", ) return parser
def main(args=None): if args is None: args = sys.argv[1:] parser = ConfigBackedParser('hg-nbmerge', description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, ) add_generic_args(parser) add_diff_args(parser) add_merge_args(parser) # Argument list, we are given base, local, remote add_filename_args(parser, ["base", "local", "remote", "merged"]) opts = parser.parse_args(args) # mergeapp expects an additional decisions arg: opts.decisions = False opts.out = opts.merged del opts.merged return nbmergeapp.main_merge(opts)
def main(args=None): if args is None: args = sys.argv[1:] parser = argparse.ArgumentParser('hg-nbmerge', description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, ) add_generic_args(parser) add_diff_args(parser) add_merge_args(parser) # Argument list, we are given base, local, remote add_filename_args(parser, ["base", "local", "remote", "merged"]) opts = parser.parse_args(args) # mergeapp expects an additional decisions arg: opts.decisions = False opts.out = opts.merged del opts.merged return nbmergeapp.main_merge(opts)
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(): """Creates an argument parser for the nbshow command.""" parser = ConfigBackedParser( description=_description, add_help=True, ) add_generic_args(parser) parser.add_argument("notebook", nargs="*", help="notebook filename(s) or - to read from stdin") # Things we can choose to show or not ignorables = parser.add_argument_group( title='ignorables', description='Set which parts of the notebook (not) to show.') ignorables.add_argument('-s', '--sources', action=IgnorableAction, help="show/ignore sources.") ignorables.add_argument('-o', '--outputs', action=IgnorableAction, help="show/ignore outputs.") ignorables.add_argument('-a', '--attachments', action=IgnorableAction, help="show/ignore attachments.") ignorables.add_argument('-m', '--metadata', action=IgnorableAction, help="show/ignore metadata.") ignorables.add_argument( '-d', '--details', action=IgnorableAction, help="show/ignore details not covered by other options.") 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') 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 _build_arg_parser(): """Creates an argument parser for the nbshow command.""" parser = argparse.ArgumentParser( description=_description, add_help=True, ) add_generic_args(parser) add_filename_args(parser, ["notebook"]) # Things we can choose to show or not parser.add_argument('-s', '--sources', action="store_true", default=False, help="show sources.") parser.add_argument('-o', '--outputs', action="store_true", default=False, help="show outputs.") parser.add_argument('-a', '--attachments', action="store_true", default=False, help="show attachments.") parser.add_argument('-m', '--metadata', action="store_true", default=False, help="show metadata.") parser.add_argument('-d', '--details', action="store_true", default=False, help="show details not covered by other options.") return parser
def _build_arg_parser(): """Creates an argument parser for the nbshow command.""" parser = argparse.ArgumentParser( description=_description, add_help=True, ) add_generic_args(parser) parser.add_argument("notebook", nargs="*", help="notebook filename(s) or - to read from stdin") # Things we can choose to show or not parser.add_argument( '-s', '--sources', action="store_true", default=False, help="show sources.") parser.add_argument( '-o', '--outputs', action="store_true", default=False, help="show outputs.") parser.add_argument( '-a', '--attachments', action="store_true", default=False, help="show attachments.") parser.add_argument( '-m', '--metadata', action="store_true", default=False, help="show metadata.") parser.add_argument( '-d', '--details', action="store_true", default=False, help="show details not covered by other options.") return parser