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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions awscli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ def find_spec(self, fullname, path, target=None):


TopLevelImportAliasFinder.add_alias_finder(sys.meta_path)

_DEFAULT_BASE_REMOTE_URL = f"https://awscli.amazonaws.com/v2/documentation/api/{__version__}" # noqa
13 changes: 13 additions & 0 deletions awscli/clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ def _update_config_chain(self):
config_store.set_config_provider(
'cli_auto_prompt', self._construct_cli_auto_prompt_chain()
)
config_store.set_config_provider(
'cli_help_output', self._construct_cli_help_output_chain()
)

def _construct_cli_region_chain(self):
providers = [
Expand Down Expand Up @@ -308,6 +311,16 @@ def _construct_cli_output_chain(self):
]
return ChainProvider(providers=providers)

def _construct_cli_help_output_chain(self):
providers = [
ScopedConfigProvider(
config_var_name='cli_help_output',
session=self.session,
),
ConstantProvider(value='terminal'),
]
return ChainProvider(providers=providers)

def _construct_cli_pager_chain(self):
providers = [
EnvironmentProvider(
Expand Down
16 changes: 14 additions & 2 deletions awscli/customizations/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,10 @@ def __init__(
command_table,
arg_table,
event_handler_class=None,
base_remote_url=None,
):
super(BasicHelp, self).__init__(
session, command_object, command_table, arg_table
session, command_object, command_table, arg_table, base_remote_url
)
# This is defined in HelpCommand so we're matching the
# casing here.
Expand Down Expand Up @@ -383,6 +384,12 @@ def examples(self):
def event_class(self):
return '.'.join(self.obj.lineage_names)

@property
def url(self):
if len(self.command_table) > 0:
return f"{self._base_remote_url}/reference/{self.event_class.replace('.', '/')}/index.html"
return f"{self._base_remote_url}/reference/{self.event_class.replace('.', '/')}.html"

def _get_doc_contents(self, attr_name):
value = getattr(self, attr_name)
if isinstance(value, BasicCommand.FROM_FILE):
Expand All @@ -408,7 +415,12 @@ def __call__(self, args, parsed_globals):
# We pass ourselves along so that we can, in turn, get passed
# to all event handlers.
docevents.generate_events(self.session, self)
self.renderer.render(self.doc.getvalue())

if self._help_output_format == 'url':
self.renderer.render(self.url.encode())
else:
self.renderer.render(self.doc.getvalue())

instance.unregister()


Expand Down
Loading