Revert "Update pyproject.toml"
[git-cola.git] / cola / dag.py
blobad15dfa65016344530ace70c0a9e42f60b88de43
1 from __future__ import absolute_import, division, print_function, unicode_literals
2 import argparse
3 import sys
5 from cola import app
6 from cola.widgets.dag import git_dag
9 def main(argv=None):
10 """Run git-dag"""
11 app.initialize()
12 args = parse_args(argv=argv)
13 return args.func(args)
16 def shortcut_launch():
17 """Run git-dag from a Windows shortcut"""
18 return main(argv=['--prompt'])
21 def parse_args(argv=None):
22 """Parse command-line arguments"""
23 if argv is None:
24 argv = sys.argv[1:]
25 parser = argparse.ArgumentParser()
26 parser.set_defaults(func=cmd_dag)
28 app.add_common_arguments(parser)
29 parser.add_argument(
30 '-c',
31 '--count',
32 '--max-count',
33 metavar='<count>',
34 type=int,
35 default=1000,
36 help='number of commits to display',
38 parser.add_argument('args', nargs='*', metavar='<args>', help='git log arguments')
39 args, rest = parser.parse_known_args(args=argv)
40 if rest:
41 # splice unknown arguments to the beginning ~
42 # these are forwarded to git-log(1).
43 args.args[:0] = rest
44 return args
47 def cmd_dag(args):
48 """Run git-dag via the `git cola dag` sub-command"""
49 context = app.application_init(args)
50 view = git_dag(context, args=args, show=False)
51 return app.application_start(context, view)