|
4 | 4 | import click |
5 | 5 |
|
6 | 6 | from repo_man.consts import REPO_TYPES_CFG |
7 | | -from repo_man.utils import get_valid_repo_types, parse_repo_types, pass_config |
| 7 | +from repo_man.utils import parse_repo_types, pass_config |
8 | 8 |
|
9 | 9 |
|
10 | 10 | @click.command(name="list", help="The type of repository to manage") |
11 | | -@click.option("-t", "--type", "repo_type", type=click.Choice(get_valid_repo_types()), show_choices=False, required=True) |
| 11 | +@click.option("-t", "--type", "repo_types", multiple=True, show_choices=False, required=True) |
12 | 12 | @pass_config |
13 | | -def list_repos(config: configparser.ConfigParser, repo_type: str): |
| 13 | +def list_repos(config: configparser.ConfigParser, repo_types: list[str]): |
14 | 14 | """List matching repositories""" |
15 | 15 |
|
16 | 16 | if not Path(REPO_TYPES_CFG).exists(): |
17 | 17 | click.echo(click.style(f"No {REPO_TYPES_CFG} file found.", fg="red")) |
18 | 18 | raise SystemExit(1) |
19 | 19 |
|
20 | 20 | valid_repo_types = parse_repo_types(config) |
| 21 | + found_repos = set() |
21 | 22 |
|
22 | | - repos = sorted(valid_repo_types[repo_type]) |
| 23 | + for repo_type in repo_types: |
| 24 | + if repo_type not in valid_repo_types: |
| 25 | + repo_list = "\n\t".join(valid_repo_types) |
| 26 | + raise click.BadParameter(f"Invalid repository type '{repo_type}'. Valid types are:\n\n\t{repo_list}") |
| 27 | + found_repos.update(valid_repo_types[repo_type]) |
| 28 | + |
| 29 | + repos = sorted(found_repos) |
23 | 30 |
|
24 | 31 | if len(repos) > 25: |
25 | 32 | click.echo_via_pager("\n".join(repos)) |
|
0 commit comments