Web-based help
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:
- Unset: default behavior opening the man page in the terminal.
-
terminal: default behavior opening the man page in the terminal. -
browser: open the man page as HTML in the default browser. -
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:
- Consider different refactor of
HelpCommandto control behavior of text documentation or the URL. - 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.