Skip to content

Commit 2d98fa5

Browse files
authored
Merge pull request aws#9741 from aws/cli-accessibility
AWS CLI accessibility improvements
2 parents 8144cbf + 8e0733d commit 2d98fa5

34 files changed

+965
-326
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "configuration",
4+
"description": "Improve accessibility of table output for ``configure list`` command (aws/aws-cli`#9547 <https://github.com/aws/aws-cli/issues/9547>`__)"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "documentation",
4+
"description": "Display required constraints to top level and nested parameters (aws/aws-cli`#9463 <https://github.com/aws/aws-cli/issues/9463>`__, aws/aws-cli`#9491 <https://github.com/aws/aws-cli/issues/9491>`__)"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "documentation",
4+
"description": "Add documentation for API parameter constraints (aws/aws-cli`#9444 <https://github.com/aws/aws-cli/issues/9444>`__)"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "help",
4+
"description": "Update message formatting when entering an invalid command to improve identification of an error (aws/aws-cli`#9737 <https://github.com/aws/aws-cli/issues/9737>`__)"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "help",
4+
"description": "Reduce output from help when entering an invalid command (aws/aws-cli`#9457 <https://github.com/aws/aws-cli/issues/9457>`__)"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "enhancement",
3+
"category": "``s3``",
4+
"description": "Add controls over progress status message frequency and multiline printing (aws/aws-cli`#9545 <https://github.com/aws/aws-cli/issues/9545>`__)"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "feature",
3+
"category": "help",
4+
"description": "Add ability to view help in a web browser or print the URL to the remote documentation website (aws/aws-cli`#9496 <https://github.com/aws/aws-cli/issues/9496>`__)"
5+
}

awscli/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,5 @@ def find_spec(self, fullname, path, target=None):
104104

105105

106106
TopLevelImportAliasFinder.add_alias_finder(sys.meta_path)
107+
108+
_DEFAULT_BASE_REMOTE_URL = f"https://awscli.amazonaws.com/v2/documentation/api/{__version__}" # noqa

awscli/argparser.py

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
)
2525
USAGE = (
2626
"aws [options] <command> <subcommand> [<subcommand> ...] [parameters]\n"
27-
"%s" % HELP_BLURB
27+
f"{HELP_BLURB}"
2828
)
2929

3030

@@ -42,9 +42,7 @@ class CommandAction(argparse.Action):
4242

4343
def __init__(self, option_strings, dest, command_table, **kwargs):
4444
self.command_table = command_table
45-
super(CommandAction, self).__init__(
46-
option_strings, dest, choices=self.choices, **kwargs
47-
)
45+
super().__init__(option_strings, dest, choices=self.choices, **kwargs)
4846

4947
def __call__(self, parser, namespace, values, option_string=None):
5048
setattr(namespace, self.dest, values)
@@ -65,10 +63,6 @@ def choices(self, val):
6563
class CLIArgParser(argparse.ArgumentParser):
6664
Formatter = argparse.RawTextHelpFormatter
6765

68-
# When displaying invalid choice error messages,
69-
# this controls how many options to show per line.
70-
ChoicesPerLine = 2
71-
7266
def _check_value(self, action, value):
7367
"""
7468
It's probably not a great idea to override a "hidden" method
@@ -77,24 +71,17 @@ def _check_value(self, action, value):
7771
"""
7872
# converted value must be one of the choices (if specified)
7973
if action.choices is not None and value not in action.choices:
80-
msg = ['Invalid choice, valid choices are:\n']
81-
for i in range(len(action.choices))[:: self.ChoicesPerLine]:
82-
current = []
83-
for choice in action.choices[i : i + self.ChoicesPerLine]:
84-
current.append('%-40s' % choice)
85-
msg.append(' | '.join(current))
74+
msg = [f"Found invalid choice '{value}'\n"]
8675
possible = get_close_matches(value, action.choices, cutoff=0.8)
8776
if possible:
88-
extra = ['\n\nInvalid choice: %r, maybe you meant:\n' % value]
77+
extra = ['Maybe you meant:\n']
8978
for word in possible:
90-
extra.append(' * %s' % word)
79+
extra.append(f' * {word}')
9180
msg.extend(extra)
9281
raise argparse.ArgumentError(action, '\n'.join(msg))
9382

9483
def parse_known_args(self, args, namespace=None):
95-
parsed, remaining = super(CLIArgParser, self).parse_known_args(
96-
args, namespace
97-
)
84+
parsed, remaining = super().parse_known_args(args, namespace)
9885
terminal_encoding = getattr(sys.stdin, 'encoding', 'utf-8')
9986
if terminal_encoding is None:
10087
# In some cases, sys.stdin won't have an encoding set,
@@ -126,8 +113,8 @@ def error(self, message):
126113
should raise an exception.
127114
"""
128115
usage_message = self.format_usage()
129-
error_message = f'{self.prog}: error: {message}\n'
130-
raise ArgParseException(f'{usage_message}\n{error_message}')
116+
error_message = f'{self.prog}: [ERROR]: {message}'
117+
raise ArgParseException(f'{error_message}\n\n{usage_message}')
131118

132119

133120
class MainArgParser(CLIArgParser):
@@ -141,7 +128,7 @@ def __init__(
141128
argument_table,
142129
prog=None,
143130
):
144-
super(MainArgParser, self).__init__(
131+
super().__init__(
145132
formatter_class=self.Formatter,
146133
add_help=False,
147134
conflict_handler='resolve',
@@ -154,7 +141,7 @@ def __init__(
154141
def _create_choice_help(self, choices):
155142
help_str = ''
156143
for choice in sorted(choices):
157-
help_str += '* %s\n' % choice
144+
help_str += f'* {choice}\n'
158145
return help_str
159146

160147
def _build(self, command_table, version_string, argument_table):
@@ -174,7 +161,7 @@ def _build(self, command_table, version_string, argument_table):
174161

175162
class ServiceArgParser(CLIArgParser):
176163
def __init__(self, operations_table, service_name):
177-
super(ServiceArgParser, self).__init__(
164+
super().__init__(
178165
formatter_class=argparse.RawTextHelpFormatter,
179166
add_help=False,
180167
conflict_handler='resolve',
@@ -196,7 +183,7 @@ def __init__(self, argument_table, command_table=None):
196183
# command_table is an optional subcommand_table. If it's passed
197184
# in, then we'll update the argparse to parse a 'subcommand' argument
198185
# and populate the choices field with the command table keys.
199-
super(ArgTableArgParser, self).__init__(
186+
super().__init__(
200187
formatter_class=self.Formatter,
201188
add_help=False,
202189
usage=USAGE,
@@ -224,9 +211,7 @@ def parse_known_args(self, args, namespace=None):
224211
namespace.help = 'help'
225212
return namespace, []
226213
else:
227-
return super(ArgTableArgParser, self).parse_known_args(
228-
args, namespace
229-
)
214+
return super().parse_known_args(args, namespace)
230215

231216

232217
class SubCommandArgParser(ArgTableArgParser):
@@ -239,9 +224,7 @@ class SubCommandArgParser(ArgTableArgParser):
239224
"""
240225

241226
def parse_known_args(self, args, namespace=None):
242-
parsed_args, remaining = super(
243-
SubCommandArgParser, self
244-
).parse_known_args(args, namespace)
227+
parsed_args, remaining = super().parse_known_args(args, namespace)
245228
if getattr(parsed_args, 'subcommand', None) is not None:
246229
new_args = self._remove_subcommand(args, parsed_args)
247230
return new_args, parsed_args.subcommand

awscli/botocore/model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class Shape:
9595
'contextParam',
9696
'clientContextParams',
9797
'requiresLength',
98+
'pattern',
9899
]
99100
MAP_TYPE = OrderedDict
100101

0 commit comments

Comments
 (0)