Skip to content

Commit 2c11aa8

Browse files
Copilotaishwaryabh
andcommitted
Only throw CliArgumentsException for pack command when help flags are 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 <37918412+aishwaryabh@users.noreply.github.com>
1 parent f7cf9b4 commit 2c11aa8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Cli/func/Actions/LocalActions/PackAction/PackAction.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using System;
45
using Azure.Functions.Cli.Common;
56
using Azure.Functions.Cli.Helpers;
67
using Azure.Functions.Cli.Interfaces;
@@ -47,8 +48,13 @@ public override ICommandLineParserResult ParseArgs(string[] args)
4748

4849
var parseResult = base.ParseArgs(args);
4950

50-
// For help display, throw CliArgumentsException to show positional arguments when no args provided
51-
if (!args.Any())
51+
// For help display, throw CliArgumentsException to show positional arguments when help is requested
52+
var helpArgs = new[] { "help", "h", "?" };
53+
var containsHelpFlag = args.Any(arg =>
54+
helpArgs.Any(ha => arg.Equals($"-{ha}", StringComparison.OrdinalIgnoreCase) ||
55+
arg.Equals($"--{ha}", StringComparison.OrdinalIgnoreCase)));
56+
57+
if (containsHelpFlag)
5258
{
5359
throw new CliArgumentsException(
5460
"Pack function app arguments.",

0 commit comments

Comments
 (0)