How to Output References in HTML from the Python CLI

Asked 2 years ago, Updated 2 years ago, 42 views

Using Python's argparse module to create the CLI.
You can use the CLI by specifying the --help argument in the terminal, but if possible, you can use it on the web.

As an image, I would like to match the contents of the help command with the web reference, such as awscli.

awscli Help Commands

$aws3listhelp

LS() LS()



NAME
       ls -

DESCRIPTION
       List S3 objects and common prefixes under a prefix or all S3 buckets.
       Note that the --output and --no-paginate arguments are ignored for this
       command

       See 'aws help' for descriptions of global parameters.

SYNOPSIS
            ls
          <S3Uri> or NONE
          [--recursive]
          [--page-size<value>]
          [--human-readable]
          [--summarize]
          [--request-payer<value>]

OPTIONS
       paths(string)

       --recursive (boolean) Command is performed on all files or objects
       under the specified directory or prefix.

awscli web reference

awscris3ls

https://docs.aws.amazon.com/cli/latest/reference/s3/ls.html

Please let me know if there are any tools or patterns that are good for outputting CLI references as HTML.
The simple method is to "give help messages to argparse and write help messages to HTML (actually sphinx), which would result in double management.

I looked at the awscli source to find out how it works, but I didn't really understand.
I understand that the contents of "Examples" seem to be loading files written in reStructuredText

https://github.com/aws/aws-cli/blob/274ee71cb3180e557a54f9445cca2b6a7a998d24/awscli/examples/s3/ls.rst

environment

  • Python 3.8
  • awscli 1.18.147

python

2022-09-30 20:13

1 Answers

The python script htmlgen appears to be calling the ProviderHelpCommand via awscli.clidriver and generating it from it.


2022-09-30 20:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.