Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3def940

Browse files
committed
reorder pre-commit sub commands
1 parent 7769915 commit 3def940

1 file changed

Lines changed: 53 additions & 53 deletions

File tree

pre_commit/main.py

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,37 @@ def main(argv=None):
131131

132132
subparsers = parser.add_subparsers(dest='command')
133133

134+
autoupdate_parser = subparsers.add_parser(
135+
'autoupdate',
136+
help="Auto-update pre-commit config to the latest repos' versions.",
137+
)
138+
_add_color_option(autoupdate_parser)
139+
_add_config_option(autoupdate_parser)
140+
autoupdate_parser.add_argument(
141+
'--tags-only', action='store_true', help='LEGACY: for compatibility',
142+
)
143+
autoupdate_parser.add_argument(
144+
'--bleeding-edge', action='store_true',
145+
help=(
146+
'Update to the bleeding edge of `master` instead of the latest '
147+
'tagged version (the default behavior).'
148+
),
149+
)
150+
autoupdate_parser.add_argument(
151+
'--repo', dest='repos', action='append', metavar='REPO',
152+
help='Only update this repository -- may be specified multiple times.',
153+
)
154+
155+
clean_parser = subparsers.add_parser(
156+
'clean', help='Clean out pre-commit files.',
157+
)
158+
_add_color_option(clean_parser)
159+
_add_config_option(clean_parser)
160+
161+
gc_parser = subparsers.add_parser('gc', help='Clean unused cached repos.')
162+
_add_color_option(gc_parser)
163+
_add_config_option(gc_parser)
164+
134165
install_parser = subparsers.add_parser(
135166
'install', help='Install the pre-commit script.',
136167
)
@@ -167,44 +198,6 @@ def main(argv=None):
167198
_add_color_option(install_hooks_parser)
168199
_add_config_option(install_hooks_parser)
169200

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-
208201
migrate_config_parser = subparsers.add_parser(
209202
'migrate-config',
210203
help='Migrate list configuration to new map configuration.',
@@ -241,6 +234,13 @@ def main(argv=None):
241234
)
242235
_add_run_options(try_repo_parser)
243236

237+
uninstall_parser = subparsers.add_parser(
238+
'uninstall', help='Uninstall the pre-commit script.',
239+
)
240+
_add_color_option(uninstall_parser)
241+
_add_config_option(uninstall_parser)
242+
_add_hook_type_option(uninstall_parser)
243+
244244
help = subparsers.add_parser(
245245
'help', help='Show help for a specific command.',
246246
)
@@ -265,29 +265,27 @@ def main(argv=None):
265265
store = Store()
266266
store.mark_config_used(args.config)
267267

268-
if args.command == 'install':
269-
return install(
268+
if args.command == 'autoupdate':
269+
if args.tags_only:
270+
logger.warning('--tags-only is the default')
271+
return autoupdate(
270272
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,
273+
tags_only=not args.bleeding_edge,
274+
repos=args.repos,
274275
)
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)
279276
elif args.command == 'clean':
280277
return clean(store)
281278
elif args.command == 'gc':
282279
return gc(store)
283-
elif args.command == 'autoupdate':
284-
if args.tags_only:
285-
logger.warning('--tags-only is the default')
286-
return autoupdate(
280+
elif args.command == 'install':
281+
return install(
287282
args.config, store,
288-
tags_only=not args.bleeding_edge,
289-
repos=args.repos,
283+
overwrite=args.overwrite, hooks=args.install_hooks,
284+
hook_type=args.hook_type,
285+
skip_on_missing_conf=args.allow_missing_config,
290286
)
287+
elif args.command == 'install-hooks':
288+
return install_hooks(args.config, store)
291289
elif args.command == 'migrate-config':
292290
return migrate_config(args.config)
293291
elif args.command == 'run':
@@ -296,6 +294,8 @@ def main(argv=None):
296294
return sample_config()
297295
elif args.command == 'try-repo':
298296
return try_repo(args)
297+
elif args.command == 'uninstall':
298+
return uninstall(hook_type=args.hook_type)
299299
else:
300300
raise NotImplementedError(
301301
'Command {} not implemented.'.format(args.command),

0 commit comments

Comments
 (0)