Look up a command and display its extracted options.
(
ctx: click.Context, name: str, raw: bool, distro: str | None, release: str | None
)
| 1056 | @click.option("--release", default=None, help="Filter by release (e.g. 26.04).") |
| 1057 | @click.pass_context |
| 1058 | def show_manpage( |
| 1059 | ctx: click.Context, name: str, raw: bool, distro: str | None, release: str | None |
| 1060 | ) -> None: |
| 1061 | """Look up a command and display its extracted options.""" |
| 1062 | if (distro is None) != (release is None): |
| 1063 | raise click.UsageError("--distro and --release must be used together.") |
| 1064 | s = store.Store(_require_db(ctx, must_exist=True), read_only=True) |
| 1065 | try: |
| 1066 | results = s.find_man_page(name, distro=distro, release=release) |
| 1067 | except errors.ProgramDoesNotExist: |
| 1068 | click.echo(f"Not found: {name}", err=True) |
| 1069 | sys.exit(1) |
| 1070 | mp = results[0] |
| 1071 | click.echo(f"source: {mp.source}") |
| 1072 | click.echo(f"name: {mp.name}") |
| 1073 | click.echo(f"synopsis: {mp.synopsis}") |
| 1074 | click.echo(f"aliases: {mp.aliases}") |
| 1075 | click.echo(f"nested_cmd: {mp.nested_cmd}") |
| 1076 | click.echo(f"subcommands: {mp.subcommands}") |
| 1077 | click.echo(f"dashless_opts: {mp.dashless_opts}") |
| 1078 | click.echo(f"extractor: {mp.extractor}") |
| 1079 | click.echo(f"options: {len(mp.options)}") |
| 1080 | click.echo("") |
| 1081 | for i, opt in enumerate(mp.options): |
| 1082 | if i > 0: |
| 1083 | click.echo("") |
| 1084 | click.echo(f" [{i}]") |
| 1085 | click.echo(f" short: {opt.short}") |
| 1086 | click.echo(f" long: {opt.long}") |
| 1087 | click.echo(f" has_argument: {opt.has_argument}") |
| 1088 | if opt.positional: |
| 1089 | click.echo(f" positional: {opt.positional}") |
| 1090 | if opt.prefix: |
| 1091 | click.echo(f" prefix: {opt.prefix}") |
| 1092 | if opt.nested_cmd: |
| 1093 | click.echo(f" nested_cmd: {opt.nested_cmd}") |
| 1094 | desc = opt.text.strip() |
| 1095 | for line in desc.split("\n"): |
| 1096 | click.echo(f" {line}") |
| 1097 | |
| 1098 | if raw: |
| 1099 | raw_mp = s.get_raw_manpage(mp.source) |
| 1100 | if raw_mp: |
| 1101 | click.echo("") |
| 1102 | click.echo("--- raw manpage ---") |
| 1103 | click.echo(raw_mp.source_text) |
| 1104 | else: |
| 1105 | click.echo("") |
| 1106 | click.echo("(no raw manpage stored)") |
| 1107 | |
| 1108 | if len(results) > 1: |
| 1109 | click.echo("") |
| 1110 | click.echo("also available:") |
| 1111 | for alt in results[1:]: |
| 1112 | click.echo(f" {alt.source} ({alt.name})") |
| 1113 | |
| 1114 | |
| 1115 | @show.command("distros") |
nothing calls this directly
no test coverage detected