Skip to content

Fix format inconsistency in SAM CLI help text#8663

Open
vicheey wants to merge 17 commits intodevelopfrom
fix-command-help-text
Open

Fix format inconsistency in SAM CLI help text#8663
vicheey wants to merge 17 commits intodevelopfrom
fix-command-help-text

Conversation

@vicheey
Copy link
Contributor

@vicheey vicheey commented Feb 17, 2026

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?

  • Migrated all commands to use the CoreCommand pattern with consistent section structure
  • Standardized option grouping across commands (e.g., "AWS Credential Options", "Configuration Options", "Other Options")
  • Implemented nested indented_section formatting for example section with descriptive titles
  • Used RowDefinition(text="\n") for consistent spacing before command in example sections
  • Removed 19 custom formatter files.
  • Added proper type hints (-> Dict, -> CommandHelpTextFormatter, -> None) to satisfy mypy
  • Created core command structures for pipeline init and bootstrap commands

What side effects does this change have?

  • Help text output format changes for all commands (improved consistency and readability)
  • Deleted 19 custom formatter files, reducing code duplication
  • All existing tests updated to match new format expectations
  • Added 2 new test files for pipeline commands

Mandatory Checklist

PRs will only be reviewed after checklist is complete

Step to Verify the Output

1. Pull the branch and set up environment

# Pull the branch
git fetch origin
git checkout <branch-name>

# Set up Python virtual environment (if not already done)
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Initialize development environment
make init

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:

  • Examples sections have single-line spacing (no blank lines between examples)
  • Text wraps properly with right padding (doesn't extend to terminal edge)
  • All formatting looks clean and readable
#!/bin/bash

# Interactive help text verification script
# Press ENTER after reviewing each command's help output

echo "==================================================================="
echo "SAM CLI Help Text Verification"
echo "==================================================================="
echo ""
echo "This script will display help text for each SAM CLI command."
echo "After each command, press ENTER to continue to the next one."
echo ""
echo "What to verify:"
echo "  ✓ Examples sections have single-line spacing (no double-spacing)"
echo "  ✓ Text uses full terminal width with proper right padding"
echo "  ✓ No text wrapping at terminal edge"
echo ""
read -p "Press ENTER to start..."

commands=(
    "samdev -h"
    "samdev init -h"
    "samdev build -h"
    "samdev local -h"
    "samdev local invoke -h"
    "samdev local start-api -h"
    "samdev local start-lambda -h"
    "samdev local generate-event -h"
    "samdev validate -h"
    "samdev deploy -h"
    "samdev delete -h"
    "samdev logs -h"
    "samdev traces -h"
    "samdev sync -h"
    "samdev package -h"
    "samdev publish -h"
    "samdev pipeline -h"
    "samdev list -h"
    "samdev docs -h"
    "samdev remote -h"
)

for cmd in "${commands[@]}"; do
    echo ""
    echo "==================================================================="
    echo "Command: $cmd"
    echo "==================================================================="
    echo ""
    eval "$cmd"
    echo ""
    echo "-------------------------------------------------------------------"
    read -p "Press ENTER to continue to next command..."
done

echo ""
echo "==================================================================="
echo "Verification Complete!"
echo "==================================================================="
echo ""
echo "All commands reviewed. If everything looks good, approve the PR!"

3. Save and run the script

# Save the script above to a file
cat > verify_help.sh << 'SCRIPT_END'
#!/bin/bash

# Interactive help text verification script
# Press ENTER after reviewing each command's help output

echo "==================================================================="
echo "SAM CLI Help Text Verification"
echo "==================================================================="
echo ""
echo "This script will display help text for each SAM CLI command."
echo "After each command, press ENTER to continue to the next one."
echo ""
echo "What to verify:"
echo "  ✓ Examples sections have single-line spacing (no double-spacing)"
echo "  ✓ Text uses full terminal width with proper right padding"
echo "  ✓ No text wrapping at terminal edge"
echo ""
read -p "Press ENTER to start..."

commands=(
    "samdev -h"
    "samdev init -h"
    "samdev build -h"
    "samdev local -h"
    "samdev local invoke -h"
    "samdev local start-api -h"
    "samdev local start-lambda -h"
    "samdev local generate-event -h"
    "samdev validate -h"
    "samdev deploy -h"
    "samdev delete -h"
    "samdev logs -h"
    "samdev traces -h"
    "samdev sync -h"
    "samdev package -h"
    "samdev publish -h"
    "samdev pipeline -h"
    "samdev list -h"
    "samdev docs -h"
    "samdev remote -h"
)

for cmd in "${commands[@]}"; do
    echo ""
    echo "==================================================================="
    echo "Command: $cmd"
    echo "==================================================================="
    echo ""
    eval "$cmd"
    echo ""
    echo "-------------------------------------------------------------------"
    read -p "✓ Verified? Press ENTER to continue to next command..."
done

echo ""
echo "==================================================================="
echo "Verification Complete!"
echo "==================================================================="
echo ""
echo "All commands reviewed. If everything looks good, approve the PR!"
SCRIPT_END

# Make it executable and run
chmod +x verify_help.sh
./verify_help.sh

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@vicheey vicheey marked this pull request as ready for review February 17, 2026 16:55
@vicheey vicheey requested a review from a team as a code owner February 17, 2026 16:55
@github-actions github-actions bot added area/package sam package command area/deploy sam deploy command area/validate sam validate command area/init sam init area/logs sam logs command area/build sam build command area/local/invoke sam local invoke command area/pipeline area/delete area/sync sam sync command pr/internal labels Feb 17, 2026
@reedham-aws
Copy link
Contributor

Do you have an example of what some of the changed commands look like before and after?

@roger-zhangg
Copy link
Member

do you have a chance to remove the new tag from the main command help as well?

sam --help

  Learn:
    docs NEW!           Launch the AWS SAM CLI documentation in a browser.

  Create an App:
    init                Initialize an AWS SAM application.

  Develop your App:
    build               Build your AWS serverless function code.
    local               Run your AWS serverless function locally.
    validate            Validate an AWS SAM template.
    sync NEW!           Sync an AWS SAM project to AWS.
    remote NEW!         Invoke or send an event to cloud resources in your AWS
                        Cloudformation stack.

  Deploy your App:
    package             Package an AWS SAM application.
    deploy              Deploy an AWS SAM application.

  Monitor your App:
    logs                Fetch AWS Cloudwatch logs for AWS Lambda Functions or
                        Cloudwatch Log groups.
    traces              Fetch AWS X-Ray traces.

  And More:
    list NEW!           Fetch the state of your AWS serverless application.

@valerena
Copy link
Contributor

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 sam local --help)
old

$ sam local --help
Usage: sam local [OPTIONS] COMMAND [ARGS]...

  Run your Serverless application locally for quick development & testing

Options:
  -h, --help  Show this message and exit.

Commands:
  callback        Send callbacks to durable function executions
  execution       Manage durable function executions
  generate-event  Generate events for Lambda functions.
  invoke          Invoke AWS serverless functions locally.
  start-api       Run & test AWS serverless functions locally as a HTTP API.
  start-lambda    Emulate AWS serverless functions locally.

vs new

$ sam local --help

Usage: sam local [OPTIONS] COMMAND [ARGS]...

  Run your Serverless application locally for quick development & testing

Options:

  -h, --help  Show this message and exit.

Commands:

  callback (NEW!)    Send callbacks to durable function executions

  execution (NEW!)   Manage durable function executions

  generate-event     Generate events for Lambda functions.

  invoke             Invoke AWS serverless functions locally.

  start-api          Run & test AWS serverless functions locally as a HTTP API.

  start-lambda       Emulate AWS serverless functions locally.

Do you know why we have all the extra space? Is that a conscious decision?

@valerena
Copy link
Contributor

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?

@vicheey
Copy link
Contributor Author

vicheey commented Feb 25, 2026

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)?

@vicheey vicheey requested a review from Vandita2020 February 27, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build sam build command area/delete area/deploy sam deploy command area/init sam init area/local/invoke sam local invoke command area/logs sam logs command area/package sam package command area/pipeline area/sync sam sync command area/validate sam validate command pr/internal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants