Example #1
0
    def __call__(self):
        values_to_add = {}

        # No config for commitizen exist
        if not self.config.path:
            config_path = self._ask_config_path()

            if "toml" in config_path:
                self.config = TomlConfig(data="", path=config_path)
            else:
                self.config = IniConfig(data="", path=config_path)

            self.config.init_empty_config_content()

            values_to_add["name"] = self._ask_name()
            tag = self._ask_tag()
            values_to_add["version"] = Version(tag).public
            values_to_add["tag_format"] = self._ask_tag_format(tag)
            self._update_config_file(values_to_add)
            out.write(
                "You can bump the version and create cangelog running:\n")
            out.info("cz bump --changelog")
            out.success("The configuration are all set.")
        else:
            # TODO: handle the case that config file exist but no value
            out.line(f"Config file {self.config.path} already exists")
Example #2
0
    def __call__(self):
        values_to_add = {}

        # No config for commitizen exist
        if not self.config.path:
            config_path = self._ask_config_path()
            if "toml" in config_path:
                self.config = TomlConfig(data="", path=config_path)
            elif "json" in config_path:
                self.config = JsonConfig(data="{}", path=config_path)
            elif "yaml" in config_path:
                self.config = YAMLConfig(data="", path=config_path)

            self.config.init_empty_config_content()

            values_to_add["name"] = self._ask_name()
            tag = self._ask_tag()
            values_to_add["version"] = Version(tag).public
            values_to_add["tag_format"] = self._ask_tag_format(tag)
            self._update_config_file(values_to_add)

            if questionary.confirm(
                    "Do you want to install pre-commit hook?").ask():
                self._install_pre_commit_hook()

            out.write(
                "You can bump the version and create changelog running:\n")
            out.info("cz bump --changelog")
            out.success("The configuration are all set.")
        else:
            out.line(f"Config file {self.config.path} already exists")
Example #3
0
    def __call__(self):
        values_to_add = {}

        # No config file exist
        if not self.config.path:
            config_path = self._ask_config_path()

            if "toml" in config_path:
                self.config = TomlConfig(data="", path=config_path)
            else:
                self.config = IniConfig(data="", path=config_path)

            self.config.init_empty_config_file()

            values_to_add["name"] = self._ask_name()
            tag = self._ask_tag()
            values_to_add["version"] = Version(tag).public
            values_to_add["tag_format"] = self._ask_tag_format(tag)
            self._update_config_file(values_to_add)
            out.write("The configuration are all set.")
        else:
            # TODO: handle the case that config file exist but no value
            out.line(f"Config file {self.config.path} already exists")
Example #4
0
def main():
    conf = config.read_cfg()
    parser = cli(data)

    # Show help if no arg provided
    if len(sys.argv) == 1:
        parser.print_help(sys.stderr)
        raise SystemExit()

    args = parser.parse_args()

    if args.name:
        conf.update({"name": args.name})

    if args.debug:
        warnings.warn("Debug will be deprecated in next major version. "
                      "Please remove it from your scripts")
        logging.getLogger("commitizen").setLevel(logging.DEBUG)

    if args.version:
        out.line(__version__)
        raise SystemExit()

    args.func(conf, vars(args))()