MCPcopy Index your code
hub / github.com/commitizen-tools/commitizen / main

Function main

commitizen/cli.py:670–723  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

668
669
670def main() -> None:
671 sys.excepthook = commitizen_excepthook
672
673 parser: argparse.ArgumentParser = cli(data)
674 argcomplete.autocomplete(parser)
675 # Show help if no arg provided
676 if len(sys.argv) == 1:
677 parser.print_help(sys.stderr)
678 raise ExpectedExit()
679
680 # This is for the command required constraint in 2.0
681 try:
682 args, unknown_args = parser.parse_known_args()
683 except SystemExit as e:
684 if e.code == 2:
685 raise NoCommandFoundError()
686 raise e
687
688 arguments = vars(args)
689 if unknown_args:
690 # Raise error for extra-args without -- separation
691 if "--" not in unknown_args:
692 raise InvalidCommandArgumentError(
693 f"Invalid commitizen arguments were found: `{' '.join(unknown_args)}`. "
694 "Please use -- separator for extra git args"
695 )
696 # Raise error for extra-args before --
697 elif unknown_args[0] != "--":
698 pos = unknown_args.index("--")
699 raise InvalidCommandArgumentError(
700 f"Invalid commitizen arguments were found before -- separator: `{' '.join(unknown_args[:pos])}`. "
701 )
702 # Log warning for -- without any extra args
703 elif len(unknown_args) == 1:
704 logger.warning(
705 "\nWARN: Incomplete commit command: received -- separator without any following git arguments\n"
706 )
707 extra_args = unknown_args[1:]
708 arguments["extra_cli_args"] = extra_args
709
710 conf = config.read_cfg(args.config)
711 args = cast("Args", args)
712 if args.name:
713 conf.update({"name": args.name})
714 elif not conf.path:
715 conf.update({"name": DEFAULT_SETTINGS["name"]})
716
717 if args.debug:
718 logging.getLogger("commitizen").setLevel(logging.DEBUG)
719 sys.excepthook = partial(sys.excepthook, debug=True)
720 if args.no_raise:
721 sys.excepthook = partial(sys.excepthook, no_raise=parse_no_raise(args.no_raise))
722
723 args.func(conf, arguments)() # type: ignore[arg-type]
724
725
726if __name__ == "__main__":

Callers 2

__main__.pyFile · 0.90
cli.pyFile · 0.85

Calls 5

ExpectedExitClass · 0.90
NoCommandFoundErrorClass · 0.90
parse_no_raiseFunction · 0.85
updateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…