Skip to content

Web-based help #9496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: cli-accessibility
Choose a base branch
from
Open

Web-based help #9496

wants to merge 8 commits into from

Conversation

kdaily
Copy link
Member

@kdaily kdaily commented May 15, 2025

Description of changes

This implementation is a proof of concept. Implementation details, interfaces, and behavior are subject to breaking changes.

Initial implementation to add in a configuration option that can open CLI help pages in the browser or print the URL to the remote CLI reference guide.

The new configuration option is available in the shared configuration file as cli_help_output. It has four valid values:

  1. Unset: default behavior opening the man page in the terminal.
  2. terminal: default behavior opening the man page in the terminal.
  3. browser: open the man page as HTML in the default browser.
  4. url: print the URL to the remote AWS CLI reference guide for the version of the AWS CLI installed.

When set to browser, a warning message is printed to the terminal notifying the user that the default web browser is being opened, and an error message in the case the browser cannot be opened.

When set to url, the value for client side paging is respected (e.g., controlled through AWS_PAGER environment variable).

Implementation notes

This refactors the existing help renderer to move the previous parent class PagingHelpRenderer to a sub-class of a HelpRenderer. It refactors to potentially send output to different destinations, currently a pager or a browser.

Then, this adds a new renderer base class called the BrowserHelpRenderer that swaps out a private method that sends rendered output to the pager with one that sends it to the browser. The rendered content is written to a temporary file and then the users default browser is opened. Separate OS-specific renders inherit, as the paging-based renderers did. An OS-specific sub-class is added that uses this behavior (PosixBrowserHelpRenderer) to render the output using groff or mandoc using html instead of ascii output, and a WindowsBrowserHelpRenderer swaps out the text writer for an HTML writer.

Help command classes (derived from HelpCommand) now have a url property. Additionally, the HelpCommand now uses its own botocore session to determine if its help should be the documentation contents or the URL.

TODO:

  1. Consider different refactor of HelpCommand to control behavior of text documentation or the URL.
  2. Add testing.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

kdaily added 5 commits April 30, 2025 16:52
implement in cli only, not botocore
Can just use the base PagingHelpRenderer, which does not do any more content conversion
kdaily added 3 commits May 15, 2025 11:20
Also adds Windows browser renderer, and reverts accidental changes to
the existing Windows renderer.
@kdaily kdaily marked this pull request as ready for review May 27, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant