Skip to content

Commit

Permalink
Minor logging and CLI update
Browse files Browse the repository at this point in the history
This commit adds a logging of files written by generator module.
Also minor change of parser options names was done for clarity.
Related modification of browser module was also performed.
  • Loading branch information
sdatko committed Nov 8, 2023
1 parent ece72ce commit aa4c447
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions znoyder/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ def get_releases(**kwargs):


def main(args) -> None:
if args.command == 'components':
if args.subcommand == 'components':
results = get_components(**vars(args))
default_output = ['name']
elif args.command == 'packages':
elif args.subcommand == 'packages':
results = get_packages(**vars(args))
default_output = ['osp-name', 'osp-distgit', 'osp-patches']
elif args.command == 'releases':
elif args.subcommand == 'releases':
results = get_releases(**vars(args))
default_output = ['ospinfo_tag_name', 'git_release_branch']
else:
Expand Down
12 changes: 6 additions & 6 deletions znoyder/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __call__(self, parser, namespace, values, option_string=None):


def extend_parser_browser(parser) -> None:
subparsers = parser.add_subparsers(dest='command', metavar='command')
subparsers = parser.add_subparsers(dest='subcommand', metavar='subcommand')
subparsers.required = True

common = ArgumentParser(add_help=False)
Expand Down Expand Up @@ -246,8 +246,8 @@ def process_arguments(argv=None) -> Namespace:
shared_parser = ArgumentParser(add_help=False)
shared_parser.add_argument(
'--log-mode',
default="both",
choices={"file", "terminal", "both"},
default='both',
choices={'file', 'terminal', 'both'},
help='Where to write the output, default is both'
)
shared_parser.add_argument(
Expand All @@ -264,15 +264,15 @@ def process_arguments(argv=None) -> Namespace:
# argparse one would override the arguments from the main parser if they
# were specified there but not in the subparser
subparsers = parser.add_subparsers(action=OverridenSubparserAction)
parser.add_argument('options', nargs=REMAINDER,
help='additional arguments to the selected command')
parser.add_argument('command', nargs=REMAINDER,
help='Znoyder command with its additional arguments')

for command_name, command_dict in COMMANDS.items():
parser_command = subparsers.add_parser(command_name,
parents=[shared_parser])
parser_command.set_defaults(
func=getattr(command_dict['module'], 'main'))
parser.epilog += " {}: {}\n".format(
parser.epilog += ' {}: {}\n'.format(
command_name, command_dict['help'])
command_dict['extend_parser_func'](parser_command)

Expand Down
3 changes: 3 additions & 0 deletions znoyder/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def generate_projects_templates(projects_pipelines_dict: dict) -> None:
)

try:
LOG.info(f'Writing {config_dest}')
templater.generate_zuul_project_template(
path=config_dest,
name=GENERATED_CONFIG_PREFIX + project_name,
Expand All @@ -219,6 +220,7 @@ def generate_projects_config(projects_pipelines_dict: dict) -> None:
GENERATED_CONFIG_PREFIX + 'projects' + GENERATED_CONFIG_EXTENSION
)

LOG.info(f'Writing {config_dest}')
templater.generate_zuul_projects_config(
path=config_dest,
projects=projects,
Expand All @@ -234,6 +236,7 @@ def generate_resources_config(projects_pipelines_dict: dict) -> None:
'osp-internal' + GENERATED_CONFIG_EXTENSION
)

LOG.info(f'Writing {config_dest}')
templater.generate_zuul_resources_config(
path=config_dest,
projects=projects,
Expand Down

0 comments on commit aa4c447

Please sign in to comment.