Questions tagged [ndesk.options]

NDesk.Options is a callback-based program option parser for C#.

NDesk.Options is a callback-based program option parser for C#. NDesk.Options has had the following releases (in reverse chronological order): NDesk.

OptionSet currently supports:

Boolean options of the form: -flag, --flag, and /flag. Boolean parameters can have a +' or-' appended to explicitly enable or disable the flag (in the same fashion as mcs -debug+). For boolean callbacks, the provided value is non-null for enabled, and null for disabled. Value options with a required value (append =' to the option name) or an optional value (append:' to the option name). The option value can either be in the current option (--opt=value) or in the following parameter (--opt value). The actual value is provided as the parameter to the callback delegate, unless it's (1) optional and (2) missing, in which case null is passed. Bundled parameters which must start with a single `-' and consists of a sequence of (optional) boolean options followed by an (optional) value-using option followed by the options's vlaue. In this manner, -abc would be a shorthand for -a -b -c, and -cvffile would be shorthand for -c -v -f=file (in the same manner as tar(1)). Option processing is disabled when -- is encountered.

14 questions
34
votes
2 answers

How to enforce required command-line options with NDesk.Options?

I was just writing a console utility and decided to use NDesk.Options for command-line parsing. My question is, How do I enforce required command-line options? I see in the docs that: options with a required value (append '=' to the option name)…
BigJoe714
  • 6,732
  • 7
  • 46
  • 50
4
votes
2 answers

How to parse a simple list of items with NDesk Options in C#

I am new to the NDesk.Options library. Can't figure out the simplest way to parse a simple list of items. Example: prog --items=item1 item2 item3 (I want to use a List items in the code) It should support quoting as well as I want to use the…
iwo
  • 405
  • 4
  • 13
3
votes
1 answer

Setting optional values using NDesk.Options

Using the accepted answer in Best way to parse command line arguments in C#? as your example, how can I make the 'r' or 'repeat' option only OPTIONALLY take a value and not REQUIRE it, and how can I set a default value if the value is not provided?…
Wes
  • 1,183
  • 3
  • 23
  • 51
2
votes
1 answer

Declaring required mutually exclusive options with ManyConsole

I am using the excellent ManyConsole extension to the great Mono.Options I was wondering whether it supports mutually exclusive required options. I think that Mono.Options does not support them and hence ManyConsole probably does not either. But I…
mark
  • 59,016
  • 79
  • 296
  • 580
1
vote
2 answers

How can I get NDesk to parse multi arg lists at the command line?

How can I get NDesk to parse multi arg lists at the command line (C#)? I have two flags that both take multiple parameters (a list of files). So one is -j and the other is -c. But I think NDesk requires each of these parameters to be preceded with…
lucidquiet
  • 6,124
  • 7
  • 51
  • 88
0
votes
0 answers

NDesk doesn't throw expected exception

NDesk doesn't throw exceptions while parsing args. When I do debug without any arguments, the next step after try is the if and not the catch section. Any suggestions? My code is: using System; using System.Collections.Generic; using…
0
votes
1 answer

ManyConsole Sending commands in a separate console

I'm making a console window that runs a game server and I'd like to add commands for various things. Since commands will require parameters I've decided to use the ManyConsole nuGet. I've made an test project and have added the built .dll to my…
Anthony
  • 301
  • 1
  • 2
  • 13
0
votes
1 answer

How to use ndesk options to add an option that takes three arguments?

I want to add an option like -D=Id1:Id2:Id3 in my command line options set. How can I do this ? This option has to be mandatory. I tried to do this: var optSet = new OptionSet() { { "D:", "Device to communicate with.", (int id1, int…
Monku
  • 2,440
  • 4
  • 33
  • 57
0
votes
0 answers

C# NDesk Options, flag with multiple values

wondering if anyone can help me out. In a C# console application, using NDESK.Options, if the user selects a certain flag (for this example let's say "other") I need to ensure that 4 values are passed (which in turn will populate 4…
0
votes
1 answer

flags priority in command line arguments using NDesk.Options. C#

I am currently using NDesk.Options to manipulate my command line arguments. The problem I encountered now is that when I run with multiple flags, the computation is done in the order the flags appear. But this is not always what I want. For example…
0
votes
4 answers

log4net log debug messages only if debug variable is set

I have a console application that is using a log4net setup for logging information to the console output only at the moment. I have various log.Debug("Debug info") statements which I only want to print out to the console if a debug flag within my…
general exception
  • 4,202
  • 9
  • 54
  • 82
0
votes
2 answers

Why does ManyConsole display public members of a CommandLine class?

I'm using ManyConsole as a command line command and options parser for a console app. All commands are defined as a command class that derives from ConsoleCommand, and then implement a specific task. I defined an intermediary base class,…
ProfK
  • 49,207
  • 121
  • 399
  • 775
0
votes
1 answer

Default method not executing when console application has no parameters

The default functionality below is not being executed when I execute myExe.exe, it is however being executed when I run myExe.exe -launch. Any thoughts on why this application isn't executing by default? According to the Documentation this should…
Ben
  • 60,438
  • 111
  • 314
  • 488
-1
votes
1 answer

How to check if Parse(args) is true or false

I have code that is not throwing any error. I have used NDesk option set and added 2 string Parameters. I can see it has pulled correct names in args. But when I uses parse(args) it is not throwing an error. So I am assuming it is working. I am…
user2897967
  • 337
  • 2
  • 8
  • 24