commandlineparser / commandlineparser/commandline

--help not quitting program.

Open
#845 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.8k
Forks
478
PR merge metrics
No merged PRs in 30d

Description

calling my console app with single parameter --help or --version is showing the help/version, but then not quitting the app. It continues to run. My setup code is as follows:

```
var result = Parser.Default.ParseArguments(args)
.WithParsed(o =>
{
if (o.Dest != null && o.Dest.Trim() != "")
{
rootOutputFolder = o.Dest.Trim();
}
else
{
// default to current folder's converted_databases/ subfolder
string? currentFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (currentFolder == null)
{
throw new Exception("Could not get current folder");
}
rootOutputFolder = Path.Combine(currentFolder, "converted_databases");
if (!Directory.Exists(rootOutputFolder))
{
DirectoryInfo di = Directory.CreateDirectory(rootOutputFolder);
}
}

if (o.Verbose)
{
db.DoLog = true;
Logger.DoOleLog = true;
}
});

public class Options
{
[Option('d', "dest", Required = false, HelpText = "Full path to root output folder for converted databases. If not specified, will default to .\\converted_databases\\")]
public string? Dest { get; set; }

[Option('v', "verbose", Required = false, HelpText = "Log all SQL queries in converter.log.")]
public bool Verbose { get; set; }
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the behavior with the shown Parser.Default.ParseArguments(args) setup and single --help or --version arguments. Trace how help and version output are handled, then verify that the process exits after displaying either message without affecting normal option parsing.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.