10
10
from colorama import init as color_init , Style
11
11
12
12
from gitup import __version__
13
- from gitup .config import (get_default_config_path , get_bookmarks , add_bookmarks ,
14
- delete_bookmarks , list_bookmarks , clean_bookmarks )
13
+ from gitup .config import (
14
+ get_default_config_path ,
15
+ get_bookmarks ,
16
+ add_bookmarks ,
17
+ delete_bookmarks ,
18
+ list_bookmarks ,
19
+ clean_bookmarks ,
20
+ )
15
21
from gitup .update import update_bookmarks , update_directories , run_command
16
22
17
23
@@ -23,71 +29,134 @@ def _build_parser():
23
29
Both relative and absolute paths are accepted by all arguments.
24
30
Direct bug reports and feature requests to
25
31
https://github.com/earwig/git-repo-updater.""" ,
26
- add_help = False )
32
+ add_help = False ,
33
+ )
27
34
28
35
group_u = parser .add_argument_group ("updating repositories" )
29
36
group_b = parser .add_argument_group ("bookmarking" )
30
37
group_a = parser .add_argument_group ("advanced" )
31
38
group_m = parser .add_argument_group ("miscellaneous" )
32
39
33
40
group_u .add_argument (
34
- 'directories_to_update' , nargs = "*" , metavar = "path" ,
41
+ "directories_to_update" ,
42
+ nargs = "*" ,
43
+ metavar = "path" ,
35
44
help = """update this repository, or all repositories it contains
36
- (if not a repo directly)""" )
45
+ (if not a repo directly)""" ,
46
+ )
37
47
group_u .add_argument (
38
- '-u' , '--update' , action = "store_true" , help = """update all bookmarks
39
- (default behavior when called without arguments)""" )
48
+ "-u" ,
49
+ "--update" ,
50
+ action = "store_true" ,
51
+ help = """update all bookmarks
52
+ (default behavior when called without arguments)""" ,
53
+ )
40
54
group_u .add_argument (
41
- '-t' , '--depth' , dest = "max_depth" , metavar = "n" , type = int , default = 3 ,
55
+ "-t" ,
56
+ "--depth" ,
57
+ dest = "max_depth" ,
58
+ metavar = "n" ,
59
+ type = int ,
60
+ default = 3 ,
42
61
help = """max recursion depth when searching for repos in subdirectories
43
- (default: 3; use 0 for no recursion, or -1 for unlimited)""" )
62
+ (default: 3; use 0 for no recursion, or -1 for unlimited)""" ,
63
+ )
44
64
group_u .add_argument (
45
- '-c' , '--current-only' , action = "store_true" , help = """only fetch the
46
- remote tracked by the current branch instead of all remotes""" )
65
+ "-c" ,
66
+ "--current-only" ,
67
+ action = "store_true" ,
68
+ help = """only fetch the
69
+ remote tracked by the current branch instead of all remotes""" ,
70
+ )
47
71
group_u .add_argument (
48
- '-f' , '--fetch-only' , action = "store_true" ,
49
- help = "only fetch remotes, don't try to fast-forward any branches" )
72
+ "-f" ,
73
+ "--fetch-only" ,
74
+ action = "store_true" ,
75
+ help = "only fetch remotes, don't try to fast-forward any branches" ,
76
+ )
50
77
group_u .add_argument (
51
- '-p' , '--prune' , action = "store_true" , help = """after fetching, delete
52
- remote-tracking branches that no longer exist on their remote""" )
78
+ "-p" ,
79
+ "--prune" ,
80
+ action = "store_true" ,
81
+ help = """after fetching, delete
82
+ remote-tracking branches that no longer exist on their remote""" ,
83
+ )
53
84
54
85
group_b .add_argument (
55
- '-a' , '--add' , dest = "bookmarks_to_add" , nargs = "+" , metavar = "path" , help = "add directory(s) as bookmarks" )
86
+ "-a" ,
87
+ "--add" ,
88
+ dest = "bookmarks_to_add" ,
89
+ nargs = "+" ,
90
+ metavar = "path" ,
91
+ help = "add directory(s) as bookmarks" ,
92
+ )
56
93
group_b .add_argument (
57
- '-d' , '--delete' , dest = "bookmarks_to_del" , nargs = "+" , metavar = "path" ,
58
- help = "delete bookmark(s) (leaves actual directories alone)" )
94
+ "-d" ,
95
+ "--delete" ,
96
+ dest = "bookmarks_to_del" ,
97
+ nargs = "+" ,
98
+ metavar = "path" ,
99
+ help = "delete bookmark(s) (leaves actual directories alone)" ,
100
+ )
59
101
group_b .add_argument (
60
- '-l' , '--list' , dest = "list_bookmarks" , action = "store_true" ,
61
- help = "list current bookmarks" )
102
+ "-l" ,
103
+ "--list" ,
104
+ dest = "list_bookmarks" ,
105
+ action = "store_true" ,
106
+ help = "list current bookmarks" ,
107
+ )
62
108
group_b .add_argument (
63
- '-n' , '--clean' , '--cleanup' , dest = "clean_bookmarks" ,
64
- action = "store_true" , help = "delete any bookmarks that don't exist" )
109
+ "-n" ,
110
+ "--clean" ,
111
+ "--cleanup" ,
112
+ dest = "clean_bookmarks" ,
113
+ action = "store_true" ,
114
+ help = "delete any bookmarks that don't exist" ,
115
+ )
65
116
group_b .add_argument (
66
- '-b' , '--bookmark-file' , nargs = "?" , metavar = "path" ,
117
+ "-b" ,
118
+ "--bookmark-file" ,
119
+ nargs = "?" ,
120
+ metavar = "path" ,
67
121
help = "use a specific bookmark config file (default: {0})" .format (
68
- get_default_config_path ()))
122
+ get_default_config_path ()
123
+ ),
124
+ )
69
125
70
126
group_a .add_argument (
71
- '-e' , '--exec' , '--batch' , dest = "command" , metavar = "command" ,
72
- help = "run a shell command on all repos" )
127
+ "-e" ,
128
+ "--exec" ,
129
+ "--batch" ,
130
+ dest = "command" ,
131
+ metavar = "command" ,
132
+ help = "run a shell command on all repos" ,
133
+ )
73
134
74
135
group_m .add_argument (
75
- '-h' , '--help' , action = "help" , help = "show this help message and exit" )
136
+ "-h" , "--help" , action = "help" , help = "show this help message and exit"
137
+ )
76
138
group_m .add_argument (
77
- '-v' , '--version' , action = "version" ,
78
- version = "gitup {0} (Python {1})" .format (
79
- __version__ , platform .python_version ()))
139
+ "-v" ,
140
+ "--version" ,
141
+ action = "version" ,
142
+ version = "gitup {0} (Python {1})" .format (__version__ , platform .python_version ()),
143
+ )
80
144
group_m .add_argument (
81
- '--selftest' , action = "store_true" ,
82
- help = "run integrated test suite and exit (pytest must be available)" )
145
+ "--selftest" ,
146
+ action = "store_true" ,
147
+ help = "run integrated test suite and exit (pytest must be available)" ,
148
+ )
83
149
84
150
return parser
85
151
152
+
86
153
def _selftest ():
87
154
"""Run the integrated test suite with pytest."""
88
155
from .test import run_tests
156
+
89
157
run_tests ()
90
158
159
+
91
160
def main ():
92
161
"""Parse arguments and then call the appropriate function(s)."""
93
162
parser = _build_parser ()
@@ -130,6 +199,7 @@ def main():
130
199
if args .update or not acted :
131
200
update_bookmarks (get_bookmarks (args .bookmark_file ), args )
132
201
202
+
133
203
def run ():
134
204
"""Thin wrapper for main() that catches KeyboardInterrupts."""
135
205
try :
0 commit comments