CHANGES: add a link to issue 890
[git-cola.git] / cola / dag.py
blob65bffa8d8aade3a27a8c08ba4ec6dfcf27faeddd
1 from __future__ import division, absolute_import, 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 winmain():
17 """Windows git-dag entrypoint"""
18 return app.winmain(main)
21 def shortcut_launch():
22 """Run git-dag from a Windows shortcut"""
23 return app.winmain(main, ['--prompt'])
26 def parse_args(argv=None):
27 """Parse command-line arguments"""
28 if argv is None:
29 argv = sys.argv[1:]
30 parser = argparse.ArgumentParser()
31 parser.set_defaults(func=cmd_dag)
33 app.add_common_arguments(parser)
34 parser.add_argument(
35 '-c',
36 '--count',
37 '--max-count',
38 metavar='<count>',
39 type=int,
40 default=1000,
41 help='number of commits to display',
43 parser.add_argument('args', nargs='*', metavar='<args>', help='git log arguments')
44 args, rest = parser.parse_known_args(args=argv)
45 if rest:
46 # splice unknown arguments to the beginning ~
47 # these are forwarded to git-log(1).
48 args.args[:0] = rest
49 return args
52 def cmd_dag(args):
53 """Run git-dag via the `git cola dag` sub-command"""
54 context = app.application_init(args)
55 view = git_dag(context, args=args, show=False)
56 return app.application_start(context, view)