36 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
0
answers
27
views
Add common option handler at root/intermediate command in tree [duplicate]
I am trying to use the System.CommandLine package to provide a C# .Net8 console application with a hierarchical command-based cli.
I'm quite happy with the library so far but there's one thing I can't ...
0
votes
1
answer
412
views
Implementing --interactive with System.CommandLine
I have a System.CommandLine .NET 9 command line application. It's mostly used for scheduled tasks and the like, but sometimes users need to run it manually.
When run manually, while the help is good, ...
3
votes
1
answer
239
views
C# / .NET - System.CommandLine: Making the command line case insensitive
This exists as an issues but it hasn't yet been resolved -
System.CommandLine: Consider optional case insensitive parsing #133
How can we make it case insensitive?
3
votes
2
answers
625
views
C# / .NET - System.CommandLine: how to overwrite the handler for --version?
How can we override the behavior of --version in C# with System.Commandline?
The default implementation unfortunately only shows the version of the app itself, which is rarely useful. If support asks ...
0
votes
1
answer
327
views
System.CommanLine Adding services.UseHostedService<T>() to commandHandler
I am currently trying to implement a couple of worker services. It would be great if I can tell it to add a service based on the command line.
Lets say I use the command "Background --service1 --...
0
votes
3
answers
217
views
Console Application with params and display a guide
I'm creating a small console application with .NET8 that requires some parameters to run. I want to add an help if the parameters are empty. I read a Microsoft document where apparently it is easy to ...
0
votes
1
answer
46
views
Best way to fallback on app.config when System.CommandLine options are not supplied?
Besides pre-processing args directly, is there any way to determine if an Option was NOT supplied (while still allowing a default value), in order to potentially fall back on reading <appsettings&...
0
votes
1
answer
474
views
Options not being added to a class which inherits from Command
I'm making a console app targeting dotnet core, using Microsofts System.CommandLine namespaces to parse commands.
I know these namespaces are in beta and alpha stages, nothing is production here.
My ...
4
votes
1
answer
4k
views
C# System.Commandline: How do I add an argument to a command so that I can pass a value to it?
The following simple Program.cs expects a single argument for a defined root command:
using System.CommandLine;
var inputArgument = new Argument<string>(
name: "--input",
...
0
votes
1
answer
359
views
How to check for specific parameter in Microsoft System.Commandline CLI
I am currently configuring a CLI command with the package System.CommandLine.
In my CommandClass I have added an option for the user to select if he wants to do a dry-run.
How do I check if the user ...
user avatar
user21804110
4
votes
1
answer
2k
views
How to pass multiple values to the same System.CommandLine option?
I would like to pass several numbers to a C# console app and have prepared a .Net Fiddle to demonstrate my issue:
private const long DEFAULT_ALPHA_VALUE = 1234567890L;
private static long[] alphas = { ...
2
votes
1
answer
188
views
Why is C# app not aborted despite the required global option missing?
I have difficulties understanding how the System.CommandLine works and have prepared a short .Net fiddle to demonstrate my issue.
I am trying to create a C# console app, which would be called with --...
5
votes
1
answer
1k
views
System.CommandLine mutally exclusive options
I am using System.CommandLine and I wanted to create a mutually exclusive option. The user either has to use --ipAddresses and pass in list of one or more IP addresses OR use --ipAddressesCsv and pass ...
2
votes
0
answers
403
views
How do I hide an alias of a command line parameter using System.CommandLine?
I'm using System.CommandLine to handle the command line parameters for an application.
I have a required parameter defined as:
var foo = new Option<string>("--foo", "...") { ...
4
votes
2
answers
1k
views
How do I tell if --help command was used in System.CommandLine? [duplicate]
I know how to tell if an option that I've created was used and how to retrieve its value:
// Add the option:
var outputOption = new Option<string>(new[] { "-o", "--output" }, ...