Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 6, 2025

This PR implements comprehensive improvements to the help display for the func pack command to provide better user experience and clearer documentation.

Changes Made

Pack Action Visibility

  • Changed ShowInHelp = false to ShowInHelp = true in PackAction.cs so the pack command now appears in general help output
  • Updated help text to include "with optional argument to pass in path of folder to pack" for clarity

Enhanced General Help (func --help)

The pack action now displays in the expected format:

Actions:
pack        Pack function app into a zip that's ready to deploy with optional argument to pass in path of folder to pack.

Arguments:
<PROJECT | SOLUTION>  The project or solution file to operate on. If a file is not specified, the command will search the current directory for one.

Options:
    --output [-o] Specifies the file path where the packed ZIP archive will be created.
    --no-build    Do not build the project before packaging. Optionally provide a directory when func pack as the first argument that has the build contents.Otherwise, default i
                  s the current directory

Action-Specific Help (func pack --help)

Completely enhanced the DisplayActionHelp() method in HelpAction.cs to show comprehensive help including:

  • Usage format: func pack [arguments] [options]
  • Description section: Shows the action's help text
  • Arguments section: Displays <PROJECT | SOLUTION> with proper description
  • Options section: Lists all available options like --output and --no-build
  • Subcommands section: Shows available runtime-specific subcommands

REFACTORED: Positional Arguments Architecture

  • Removed CliArgumentsException approach: No longer uses exception-based pattern for displaying arguments in help
  • Standard argument parsing: Now handles positional arguments like other actions (DeployAction, InitAction) by extracting them manually before calling base.ParseArgs()
  • Enhanced BaseAction class: Added GetPositionalArguments() virtual method that actions can override to declare their positional arguments
  • Improved help system: Modified HelpAction to use the new GetPositionalArguments() method instead of relying on exceptions
  • Maintains backward compatibility: Normal pack operation continues to work exactly as before
  • Consistent with framework patterns: Follows the same argument handling approach used by other actions in the codebase

NEW: ConsoleApp Help Routing

  • Enhanced ConsoleApp.Parse(): Updated the argument parsing logic to properly route help flags to action-specific help
  • Action-specific help support: When help flags (--help, -h, -?) are passed with specific actions, the system now shows action-specific help instead of general help
  • Preserved existing behavior: General help commands (func --help, func help) continue to work as before
  • Improved user experience: Commands like func pack --help now show comprehensive pack-specific documentation

Testing

  • Added comprehensive unit tests in HelpActionTests.cs to validate the new help format
  • Tests ensure action-specific help includes all required sections
  • Validates that usage format follows the correct pattern

Example Output

When users run func pack --help, they will see:

image

This provides users with clear, comprehensive documentation about how to use the pack command and its available options.

Fixes #4632.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Clean up Help action CLI Clean up Help action CLI for pack command Sep 6, 2025
@Copilot Copilot AI requested a review from aishwaryabh September 6, 2025 00:50
Copilot finished work on behalf of aishwaryabh September 6, 2025 00:50
… present

Changed the condition in PackAction.ParseArgs() to only throw CliArgumentsException
when args contain --help, -h, or -? flags, instead of when no args are provided.
This ensures the help display behavior only triggers when explicitly requested.

Addresses feedback from @aishwaryabh in comment 2342407401.

Co-authored-by: aishwaryabh <[email protected]>
Copy link
Contributor Author

Copilot AI commented Sep 11, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • azfunc.pkgs.visualstudio.com
    • Triggering command: dotnet build src/Cli/func/Azure.Functions.Cli.csproj --no-restore (dns block)
    • Triggering command: dotnet restore src/Cli/func/Azure.Functions.Cli.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Copilot Copilot AI requested a review from aishwaryabh September 11, 2025 21:57
Copilot finished work on behalf of aishwaryabh September 11, 2025 21:57
Copy link
Contributor Author

Copilot AI commented Sep 11, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • azfunc.pkgs.visualstudio.com
    • Triggering command: dotnet build src/Cli/func/Azure.Functions.Cli.csproj --no-restore (dns block)
    • Triggering command: dotnet restore src/Cli/func/Azure.Functions.Cli.csproj (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Copilot Copilot AI changed the title Clean up Help action CLI for pack command Clean up Help action CLI for pack command with refactored argument parsing Sep 11, 2025
@Copilot Copilot AI requested a review from aishwaryabh September 11, 2025 22:14
Copilot finished work on behalf of aishwaryabh September 11, 2025 22:14
@aishwaryabh
Copy link
Contributor

@copilot can you update ConsoleApp so that if I pass in any action (such as func pack --help or func pack -h it should launch the help action with the correct action? So func pack -h should show the help menu of for the pack action

Copy link
Contributor Author

Copilot AI commented Sep 12, 2025

@copilot can you update ConsoleApp so that if I pass in any action (such as func pack --help or func pack -h it should launch the help action with the correct action? So func pack -h should show t...

I've updated the ConsoleApp to properly handle help flags when passed to specific actions like func pack --help or func pack -h.

The key changes:

  1. Modified the parsing logic: Removed the || isHelp condition that was preventing action-specific help
  2. Added action-specific help detection: After parsing the action, if help was requested, it now creates a HelpAction with the specific action context

Now func pack --help will show the comprehensive pack action-specific help including usage, description, arguments, options, and subcommands, while maintaining all existing help functionality for general commands.

Commit: 808ccd8

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • azfunc.pkgs.visualstudio.com
    • Triggering command: dotnet build src/Cli/func/Azure.Functions.Cli.csproj --no-restore (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@Copilot Copilot AI changed the title Clean up Help action CLI for pack command with refactored argument parsing Clean up Help action CLI for pack command with refactored argument parsing and ConsoleApp help routing Sep 12, 2025
Copilot finished work on behalf of aishwaryabh September 12, 2025 00:51
@aishwaryabh aishwaryabh marked this pull request as ready for review September 12, 2025 15:13
@aishwaryabh aishwaryabh requested a review from a team as a code owner September 12, 2025 15:13
@aishwaryabh aishwaryabh merged commit ba7d29c into main Sep 15, 2025
36 checks passed
@aishwaryabh aishwaryabh deleted the copilot/fix-4632 branch September 15, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up Help action CLI

4 participants