def parse_args(): parser = ArgumentParser() parser.add_argument('filename', metavar='<filename>', help='git-rebase-todo file to edit') app.add_common_arguments(parser) return parser.parse_args()
def parse_args(argv=None): """Parse command-line arguments""" if argv is None: argv = sys.argv[1:] parser = argparse.ArgumentParser() parser.set_defaults(func=cmd_dag) app.add_common_arguments(parser) parser.add_argument('-c', '--count', '--max-count', metavar='<count>', type=int, default=1000, help='number of commits to display') parser.add_argument('args', nargs='*', metavar='<args>', help='git log arguments') args, rest = parser.parse_known_args(args=argv) if rest: # splice unknown arguments to the beginning ~ # these are forwarded to git-log(1). args.args[:0] = rest return args
def add_command(parent, name, description, func): parser = parent.add_parser(str(name), help=description) parser.set_defaults(func=func) add_common_arguments(parser) return parser
def test_add_common_arguments(self): # If the function doesn't throw an exception we are happy. parser = argparse.ArgumentParser() app.add_common_arguments(parser)
def test_add_common_arguments(): # If the function doesn't throw an exception we are happy. parser = argparse.ArgumentParser() assert hasattr(app, 'add_common_arguments') app.add_common_arguments(parser)
def test_add_common_arguments(self): # If the function doesn't throw an exception we are happy. parser = argparse.ArgumentParser() self.assertTrue(hasattr(app, 'add_common_arguments')) app.add_common_arguments(parser)