def config(ctx, view: bool, section: str) -> None: """ Configure your general settings and Github credentials for reuse. Available options (sections) are: \b - general: set your fullname, email and Github username - pat: set your Github personal access token for Github repository creation - all: calls general and pat """ if view: ConfigCommand.view_current_config() sys.exit(0) if section == 'general': # set the full_name and email for reuse in the creation process ConfigCommand.config_general_settings() elif section == 'pat': # set github username and encrypted personal access token ConfigCommand.config_pat() elif section == 'all': # set everything ConfigCommand.all_settings() # empty section argument causes a customized error elif not section: HelpErrorHandling.args_not_provided(ctx, 'config') # check if a similar section handle can be used/suggested else: ConfigCommand.similar_handle(section)
def info(ctx, handle: str) -> None: """ Get detailed info on a cookietemple template domain or a single template. list only provides an overview of all templates. Info provides a long description for a specific subset of templates. Pass a domain, language or full handle (e.g. cli-python). """ if not handle: HelpErrorHandling.args_not_provided(ctx, 'info') else: template_info = TemplateInfo() template_info.show_info(handle.lower())
def bump_version(ctx, new_version, project_dir, downgrade) -> None: """ Bump the version of an existing cookietemple project. INFO on valid versions: All versions must match the format like 1.0.0 or 1.1.0-SNAPSHOT; these are the only valid version formats cookietemple allows. A valid version therefore contains a three digits (in the range from 0 to however large it will grow) separated by two dots. Optional is the -SNAPSHOT at the end (for JVM templates especially). NOTE that versions like 1.2.3.4 or 1.2 WILL NOT be recognized as valid versions as well as no substring of them will be recognized. Unless the user uses downgrade mode via the -d flag, a downgrade of a version is never allowed. Note that bump-version with the new version equals the current version is never allowed, either with or without -d. """ if not new_version: HelpErrorHandling.args_not_provided(ctx, 'bump-version') else: # if the path entered ends with a trailing slash remove it for consistent output if str(project_dir).endswith('/'): project_dir = Path(str(project_dir).replace(str(project_dir)[len(str(project_dir)) - 1:], '')) version_bumper = VersionBumper(project_dir, downgrade) # lint before run bump-version version_bumper.lint_before_bump() # only run bump-version if conditions are met if version_bumper.can_run_bump_version(new_version): # only run "sanity" checker when the downgrade flag is not set if not downgrade: # if the check fails, ask the user for confirmation if version_bumper.check_bump_range(version_bumper.CURRENT_VERSION.split('-')[0], new_version.split('-')[0]): version_bumper.bump_template_version(new_version, project_dir) elif cookietemple_questionary_or_dot_cookietemple(function='confirm', question=f'Bumping from {version_bumper.CURRENT_VERSION} to {new_version} seems not reasonable.\n' f'Do you really want to bump the project version?', default='n'): console.print('\n') version_bumper.bump_template_version(new_version, project_dir) else: version_bumper.bump_template_version(new_version, project_dir) else: sys.exit(1)