MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / main

Function main

commitizen/cli.py:674–727  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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