1212from pre_commit .commands .autoupdate import autoupdate
1313from pre_commit .commands .clean import clean
1414from pre_commit .commands .gc import gc
15+ from pre_commit .commands .init_templatedir import init_templatedir
1516from pre_commit .commands .install_uninstall import install
1617from pre_commit .commands .install_uninstall import install_hooks
1718from pre_commit .commands .install_uninstall import uninstall
@@ -131,6 +132,51 @@ def main(argv=None):
131132
132133 subparsers = parser .add_subparsers (dest = 'command' )
133134
135+ autoupdate_parser = subparsers .add_parser (
136+ 'autoupdate' ,
137+ help = "Auto-update pre-commit config to the latest repos' versions." ,
138+ )
139+ _add_color_option (autoupdate_parser )
140+ _add_config_option (autoupdate_parser )
141+ autoupdate_parser .add_argument (
142+ '--tags-only' , action = 'store_true' , help = 'LEGACY: for compatibility' ,
143+ )
144+ autoupdate_parser .add_argument (
145+ '--bleeding-edge' , action = 'store_true' ,
146+ help = (
147+ 'Update to the bleeding edge of `master` instead of the latest '
148+ 'tagged version (the default behavior).'
149+ ),
150+ )
151+ autoupdate_parser .add_argument (
152+ '--repo' , dest = 'repos' , action = 'append' , metavar = 'REPO' ,
153+ help = 'Only update this repository -- may be specified multiple times.' ,
154+ )
155+
156+ clean_parser = subparsers .add_parser (
157+ 'clean' , help = 'Clean out pre-commit files.' ,
158+ )
159+ _add_color_option (clean_parser )
160+ _add_config_option (clean_parser )
161+
162+ gc_parser = subparsers .add_parser ('gc' , help = 'Clean unused cached repos.' )
163+ _add_color_option (gc_parser )
164+ _add_config_option (gc_parser )
165+
166+ init_templatedir_parser = subparsers .add_parser (
167+ 'init-templatedir' ,
168+ help = (
169+ 'Install hook script in a directory intended for use with '
170+ '`git config init.templateDir`.'
171+ ),
172+ )
173+ _add_color_option (init_templatedir_parser )
174+ _add_config_option (init_templatedir_parser )
175+ init_templatedir_parser .add_argument (
176+ 'directory' , help = 'The directory in which to write the hook script.' ,
177+ )
178+ _add_hook_type_option (init_templatedir_parser )
179+
134180 install_parser = subparsers .add_parser (
135181 'install' , help = 'Install the pre-commit script.' ,
136182 )
@@ -167,44 +213,6 @@ def main(argv=None):
167213 _add_color_option (install_hooks_parser )
168214 _add_config_option (install_hooks_parser )
169215
170- uninstall_parser = subparsers .add_parser (
171- 'uninstall' , help = 'Uninstall the pre-commit script.' ,
172- )
173- _add_color_option (uninstall_parser )
174- _add_config_option (uninstall_parser )
175- _add_hook_type_option (uninstall_parser )
176-
177- clean_parser = subparsers .add_parser (
178- 'clean' , help = 'Clean out pre-commit files.' ,
179- )
180- _add_color_option (clean_parser )
181- _add_config_option (clean_parser )
182-
183- gc_parser = subparsers .add_parser ('gc' , help = 'Clean unused cached repos.' )
184- _add_color_option (gc_parser )
185- _add_config_option (gc_parser )
186-
187- autoupdate_parser = subparsers .add_parser (
188- 'autoupdate' ,
189- help = "Auto-update pre-commit config to the latest repos' versions." ,
190- )
191- _add_color_option (autoupdate_parser )
192- _add_config_option (autoupdate_parser )
193- autoupdate_parser .add_argument (
194- '--tags-only' , action = 'store_true' , help = 'LEGACY: for compatibility' ,
195- )
196- autoupdate_parser .add_argument (
197- '--bleeding-edge' , action = 'store_true' ,
198- help = (
199- 'Update to the bleeding edge of `master` instead of the latest '
200- 'tagged version (the default behavior).'
201- ),
202- )
203- autoupdate_parser .add_argument (
204- '--repo' , dest = 'repos' , action = 'append' , metavar = 'REPO' ,
205- help = 'Only update this repository -- may be specified multiple times.' ,
206- )
207-
208216 migrate_config_parser = subparsers .add_parser (
209217 'migrate-config' ,
210218 help = 'Migrate list configuration to new map configuration.' ,
@@ -241,6 +249,13 @@ def main(argv=None):
241249 )
242250 _add_run_options (try_repo_parser )
243251
252+ uninstall_parser = subparsers .add_parser (
253+ 'uninstall' , help = 'Uninstall the pre-commit script.' ,
254+ )
255+ _add_color_option (uninstall_parser )
256+ _add_config_option (uninstall_parser )
257+ _add_hook_type_option (uninstall_parser )
258+
244259 help = subparsers .add_parser (
245260 'help' , help = 'Show help for a specific command.' ,
246261 )
@@ -265,29 +280,32 @@ def main(argv=None):
265280 store = Store ()
266281 store .mark_config_used (args .config )
267282
268- if args .command == 'install' :
269- return install (
283+ if args .command == 'autoupdate' :
284+ if args .tags_only :
285+ logger .warning ('--tags-only is the default' )
286+ return autoupdate (
270287 args .config , store ,
271- overwrite = args .overwrite , hooks = args .install_hooks ,
272- hook_type = args .hook_type ,
273- skip_on_missing_conf = args .allow_missing_config ,
288+ tags_only = not args .bleeding_edge ,
289+ repos = args .repos ,
274290 )
275- elif args .command == 'install-hooks' :
276- return install_hooks (args .config , store )
277- elif args .command == 'uninstall' :
278- return uninstall (hook_type = args .hook_type )
279291 elif args .command == 'clean' :
280292 return clean (store )
281293 elif args .command == 'gc' :
282294 return gc (store )
283- elif args .command == 'autoupdate' :
284- if args .tags_only :
285- logger .warning ('--tags-only is the default' )
286- return autoupdate (
295+ elif args .command == 'install' :
296+ return install (
287297 args .config , store ,
288- tags_only = not args .bleeding_edge ,
289- repos = args .repos ,
298+ overwrite = args .overwrite , hooks = args .install_hooks ,
299+ hook_type = args .hook_type ,
300+ skip_on_missing_config = args .allow_missing_config ,
290301 )
302+ elif args .command == 'init-templatedir' :
303+ return init_templatedir (
304+ args .config , store ,
305+ args .directory , hook_type = args .hook_type ,
306+ )
307+ elif args .command == 'install-hooks' :
308+ return install_hooks (args .config , store )
291309 elif args .command == 'migrate-config' :
292310 return migrate_config (args .config )
293311 elif args .command == 'run' :
@@ -296,6 +314,8 @@ def main(argv=None):
296314 return sample_config ()
297315 elif args .command == 'try-repo' :
298316 return try_repo (args )
317+ elif args .command == 'uninstall' :
318+ return uninstall (hook_type = args .hook_type )
299319 else :
300320 raise NotImplementedError (
301321 'Command {} not implemented.' .format (args .command ),
0 commit comments