MCPcopy
hub / github.com/pre-commit/pre-commit / main

Function main

pre_commit/main.py:202–450  ·  view source on GitHub ↗
(argv: Sequence[str] | None = None)

Source from the content-addressed store, hash-verified

200
201
202def main(argv: Sequence[str] | None = None) -> int:
203 argv = argv if argv is not None else sys.argv[1:]
204 parser = argparse.ArgumentParser(prog='pre-commit')
205
206 # https://stackoverflow.com/a/8521644/812183
207 parser.add_argument(
208 '-V', '--version',
209 action='version',
210 version=f'%(prog)s {C.VERSION}',
211 )
212
213 subparsers = parser.add_subparsers(dest='command')
214
215 def _add_cmd(name: str, *, help: str) -> argparse.ArgumentParser:
216 parser = subparsers.add_parser(name, help=help)
217 add_color_option(parser)
218 return parser
219
220 autoupdate_parser = _add_cmd(
221 'autoupdate',
222 help="Auto-update pre-commit config to the latest repos' versions.",
223 )
224 _add_config_option(autoupdate_parser)
225 autoupdate_parser.add_argument(
226 '--bleeding-edge', action='store_true',
227 help=(
228 'Update to the bleeding edge of `HEAD` instead of the latest '
229 'tagged version (the default behavior).'
230 ),
231 )
232 autoupdate_parser.add_argument(
233 '--freeze', action='store_true',
234 help='Store "frozen" hashes in `rev` instead of tag names',
235 )
236 autoupdate_parser.add_argument(
237 '--repo', dest='repos', action='append', metavar='REPO', default=[],
238 help='Only update this repository -- may be specified multiple times.',
239 )
240 autoupdate_parser.add_argument(
241 '-j', '--jobs', type=int, default=1,
242 help='Number of threads to use. (default %(default)s).',
243 )
244
245 _add_cmd('clean', help='Clean out pre-commit files.')
246
247 _add_cmd('gc', help='Clean unused cached repos.')
248
249 hazmat_parser = _add_cmd(
250 'hazmat', help='Composable tools for rare use in hook `entry`.',
251 )
252 hazmat.add_parsers(hazmat_parser)
253
254 init_templatedir_parser = _add_cmd(
255 'init-templatedir',
256 help=(
257 'Install hook script in a directory intended for use with '
258 '`git config init.templateDir`.'
259 ),

Callers 2

__main__.pyFile · 0.90
main.pyFile · 0.70

Calls 15

mark_config_usedMethod · 0.95
add_color_optionFunction · 0.90
error_handlerFunction · 0.90
logging_handlerFunction · 0.90
StoreClass · 0.90
autoupdateFunction · 0.90
cleanFunction · 0.90
gcFunction · 0.90
hook_implFunction · 0.90
installFunction · 0.90
init_templatedirFunction · 0.90
install_hooksFunction · 0.90

Tested by

no test coverage detected