doc: remove empty line
[git-cola.git] / cola / dag.py
bloba2dde23ef8065f2c04405778e056565ae0399729
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 args = parse_args(argv=argv)
12 return args.func(args)
15 def winmain():
16 """Windows git-dag entrypoint"""
17 return app.winmain(main)
20 def shortcut_launch():
21 """Run git-dag from a Windows shortcut"""
22 return app.winmain(main, ['--prompt'])
25 def parse_args(argv=None):
26 """Parse command-line arguments"""
27 if argv is None:
28 argv = sys.argv[1:]
29 parser = argparse.ArgumentParser()
30 parser.set_defaults(func=cmd_dag)
32 app.add_common_arguments(parser)
33 parser.add_argument('-c', '--count', '--max-count', metavar='<count>',
34 type=int, default=1000,
35 help='number of commits to display')
36 parser.add_argument('args', nargs='*', metavar='<args>',
37 help='git log arguments')
38 args, rest = parser.parse_known_args(args=argv)
39 if rest:
40 # splice unknown arguments to the beginning ~
41 # these are forwarded to git-log(1).
42 args.args[:0] = rest
43 return args
46 def cmd_dag(args):
47 """Run git-dag via the `git cola dag` sub-command"""
48 context = app.application_init(args)
49 view = git_dag(context, args=args, settings=args.settings, show=False)
50 return app.application_start(context, view)