Skip to content

Commit

Permalink
Dont show an error message when --help is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
alnlarsen committed Jun 19, 2024
1 parent 0c96c5e commit e136e36
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Engine/Cli/CliActionExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,14 @@ string getVersion()
}
string tapCommand = OperatingSystem.Current == OperatingSystem.Windows ? "tap.exe" : "tap";

if (args.Length != 0)
var helpOptions = new string[] { "--help", "-help", "-h" };
bool isHelp = args.Length == 0 || args.Any(a => helpOptions.Contains(a.ToLower()));

if (!isHelp)
{
log.Error($"\"{tapCommand} {string.Join(" ", args)}\" is not a recognized command.");
}

log.Info("OpenTAP Command Line Interface ({0})", getVersion());
log.Info($"Usage: \"{tapCommand} <command> [<subcommand(s)>] [<args>]\"\n");

Expand All @@ -304,19 +308,22 @@ string getVersion()

log.Info($"\nRun \"{tapCommand} <command> [<subcommand(s)>] -h\" to get additional help for a specific command.\n");

if (args.Length == 0 || args.Any(s => s.ToLower() == "--help" || s.ToLower() == "-h"))
if (isHelp)
return (int)ExitCodes.Success;
else
return (int)ExitCodes.ArgumentParseError;
}

if (SelectedAction != TypeData.FromType(typeof(RunCliAction)) && UserInput.Interface == null) // RunCliAction has --non-interactive flag and custom platform interaction handling.
CliUserInputInterface.Load();

ICliAction packageAction = null;
try{
try
{
packageAction = (ICliAction)SelectedAction.CreateInstance();
}catch(TargetInvocationException e1) when (e1.InnerException is System.ComponentModel.LicenseException e){
}
catch (TargetInvocationException e1) when (e1.InnerException is System.ComponentModel.LicenseException e)
{
log.Error("Unable to load CLI Action '{0}'", SelectedAction.GetDisplayAttribute().GetFullName());
log.Info("{0}", e.Message);
return (int)ExitCodes.UnknownCliAction;
Expand Down

0 comments on commit e136e36

Please sign in to comment.