Skip to content

Commit

Permalink
docs: include subcommands in the auto generated docs for the CLI
Browse files Browse the repository at this point in the history
Signed-off-by: Renan Rodrigo <[email protected]>
  • Loading branch information
renanrodrigo committed Sep 3, 2024
1 parent 48f5e9a commit 9b1a4ca
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tools/clidocgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

MANPAGE_TEMPLATE = """\
.TP
.BR "{name}" " {usage_options}"
.BR "{indent}{name}" " {usage_options}"
{description}
"""


def _build_manpage_entry(command: ProCommand) -> str:
def _build_manpage_entry(command: ProCommand, indent: str = "") -> str:
# the usage line looks like
# usage: <prog> <options>
# we wanto only the <options>
Expand All @@ -29,6 +29,7 @@ def _build_manpage_entry(command: ProCommand) -> str:
usage_options = " ".join(options_line.split())

return MANPAGE_TEMPLATE.format(
indent=indent,
name=command.name,
usage_options=usage_options,
description=command.description,
Expand All @@ -39,6 +40,8 @@ def _generate_manpage_section():
result = ""
for command in COMMANDS:
result += _build_manpage_entry(command)
for subcommand in command.subcommands:
result += _build_manpage_entry(subcommand, indent=" " * 4)

with open("./ubuntu-advantage.1.template", "r") as f:
template = f.read()
Expand Down
28 changes: 28 additions & 0 deletions ubuntu-advantage.1
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ This information can be later used for triaging/debugging issues.
.BR "config" " [-h] {show,set,unset} ..."
Manage Ubuntu Pro Client configuration on this machine

.TP
.BR " show" " [-h] [key]"
Show customizable configuration settings

.TP
.BR " set" " [-h] key_value_pair"
Set and apply Ubuntu Pro configuration settings

.TP
.BR " unset" " [-h] key"
Unset an Ubuntu Pro configuration setting, restoring the default value.

.TP
.BR "detach" " [-h] [--assume-yes] [--format {cli,json}]"
Detach this machine from an Ubuntu Pro subscription.
Expand Down Expand Up @@ -173,6 +185,22 @@ listed in the output.
.BR "system" " [-h] {reboot-required} ..."
Outputs system-related information about Pro services

.TP
.BR " reboot-required" " [-h]"
Report the current reboot-required status for the machine.

This command will output one of the three following states
for the machine regarding reboot:

* no: The machine doesn't require a reboot
* yes: The machine requires a reboot
* yes-kernel-livepatches-applied: There are only kernel-related
packages that require a reboot, but Livepatch has already provided
patches for the current running kernel. The machine still needs a
reboot, but you can assess if the reboot can be performed in the
nearest maintenance window.





Expand Down

0 comments on commit 9b1a4ca

Please sign in to comment.