log: set the focus proxy to the output text
[git-cola.git] / cola / dag.py
blob27dfe5c88d8281df2eff82a16b487f3e4fb71f7c
1 import argparse
2 import sys
4 from cola import app
5 from cola.widgets.dag import git_dag
8 def main(argv=None):
9 """Run git-dag"""
10 app.initialize()
11 args = parse_args(argv=argv)
12 return args.func(args)
15 def shortcut_launch():
16 """Run git-dag from a Windows shortcut"""
17 return main(argv=['--prompt'])
20 def parse_args(argv=None):
21 """Parse command-line arguments"""
22 if argv is None:
23 argv = sys.argv[1:]
24 parser = argparse.ArgumentParser()
25 parser.set_defaults(func=cmd_dag)
27 app.add_common_arguments(parser)
28 parser.add_argument(
29 '-c',
30 '--count',
31 '--max-count',
32 metavar='<count>',
33 type=int,
34 default=1000,
35 help='number of commits to display',
37 parser.add_argument(
38 'args', nargs=argparse.REMAINDER, metavar='<args>', help='git log arguments'
40 args, rest = parser.parse_known_args(args=argv)
41 if rest:
42 # splice unknown arguments to the beginning ~
43 # these are forwarded to git-log(1).
44 args.args[:0] = rest
45 return args
48 def cmd_dag(args):
49 """Run git-dag via the `git cola dag` sub-command"""
50 context = app.application_init(args)
51 view = git_dag(context, args=args, show=False)
52 return app.application_start(context, view)