Fix format inconsistency in SAM CLI help text#8663
Conversation
|
Do you have an example of what some of the changed commands look like before and after? |
|
do you have a chance to remove the new tag from the main command help as well? |
|
I personally don't like all the extra space that some of the SAM CLI help outputs had, and now it looks like now we're unifying all the commands to have that extra space. (for example vs new Do you know why we have all the extra space? Is that a conscious decision? |
|
Now in the code I see that it's not just "a format thing", but we explicitly add new lines everywhere. Do we like that? |
Before the changes, some command had space between option description while some didn't. For consistency, either add space or remove all space. I chose to add because it provided clear separation especially for multiline description. Do you prefer no line like the before in here: #8663 (comment)? |
reedham-aws
left a comment
There was a problem hiding this comment.
I admittedly didn't review all 138 files, but LGTM.
valerena
left a comment
There was a problem hiding this comment.
I really like the changes! I added a few comments of some minor things and some other "good to have", but that are not really necessary and we can think about doing them later.
| return CommandHelpTextFormatter( | ||
| additive_justification=3, | ||
| options=ALL_OPTIONS, | ||
| width=self.terminal_width, |
There was a problem hiding this comment.
I see in CommandHelpTextFormatter that if width is not passed it will use terminal_width anyway. Can we just not pass it from every formatter?
| class CustomFormatterContext(Context): | ||
| formatter_class = BuildCommandHelpTextFormatter | ||
| def make_formatter(self): | ||
| return CommandHelpTextFormatter( | ||
| additive_justification=3, | ||
| options=ALL_OPTIONS, | ||
| width=self.terminal_width, | ||
| max_width=self.max_content_width, | ||
| ) | ||
|
|
||
| context_class = CustomFormatterContext |
There was a problem hiding this comment.
I see that this class is basically the same all the time except for the options (and some with additive_justification). It would be nice if we could have a function to create this class dynamically.
I'm not sure if this is the best syntax to do it, but something like this:
def create_custom_formatter_context(options, additive_justification=None):
class CustomFormatterContext(Context):
def make_formatter(self):
return CommandHelpTextFormatter(
additive_justification=additive_justification,
options=options,
max_width=self.max_content_width,
)
return CustomFormatterContextthat you can then use like this:
from commands.common.formatters import create_custom_formatter_context
...
...
...
context_class = create_custom_formatter_context(ALL_OPTIONS, additive_justification=3)| """ | ||
| Delete Core Command | ||
| """ |
There was a problem hiding this comment.
The great majority of the __init__.py files for other commands don't have any contents (it's usually not very useful)
| name="Learn more about configuration files at: " | ||
| "https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html." |
There was a problem hiding this comment.
We probably want this string defined once and used everywhere?
| @@ -0,0 +1 @@ | |||
| """Pipeline bootstrap core command""" | |||
There was a problem hiding this comment.
Same about the __init__.py file (don't add contents to it)
| """ | ||
| Publish Command Core | ||
| """ |
| """ | ||
| Traces Command Core | ||
| """ |
Which issue(s) does this change fix?
Fix format inconsistency issue across SAM CLI help text.
Why is this change necessary?
SAM CLI commands had inconsistent help text formatting with different section structures, spacing, and organization. Some commands used custom formatters while others used the base CoreCommand pattern. This inconsistency made the CLI harder to read and maintain.
How does it address the issue?
CoreCommandpattern with consistent section structureindented_sectionformatting for example section with descriptive titlesRowDefinition(text="\n")for consistent spacing before command in example sectionsWhat side effects does this change have?
Mandatory Checklist
PRs will only be reviewed after checklist is complete
design-document))
Step to Verify the Output
1. Pull the branch and set up environment
2. Verify the fix
Run the following interactive script to review help text for all commands. The script will pause after each command so you can verify:
3. Save and run the script
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.