GithubHelp home page GithubHelp logo

fclp / fluent-command-line-parser Goto Github PK

View Code? Open in Web Editor NEW
529.0 32.0 85.0 1.1 MB

A simple, strongly typed .NET C# command line parser library using a fluent easy to use interface

License: Other

C# 100.00%

fluent-command-line-parser's Introduction

Fluent Command Line Parser

A simple, strongly typed .NET C# command line parser library using a fluent easy to use interface.

TeamCity Badge Nuget Badge

Download

See what's new in v1.4.3.

You can download the latest release from CodeBetter's TeamCity server

You can also install using NuGet via the command line

cmd> nuget install FluentCommandLineParser

Or use the Package Manager console in Visual Studio:

PM> Install-Package FluentCommandLineParser

.:NEW:. Git like commands!

Currently in pre-release, see this Stack Overflow post for example usage, and either use this pre-release Nuget package or get the assemblies (including signed named assemblies) from the latest build on teamcity.jetbrains.com

Usage

using Fclp;

public class ApplicationArguments
{
   public int RecordId { get; set; }
   public bool Silent { get; set; }
   public string NewValue { get; set; }
}

static void Main(string[] args)
{
   // create a generic parser for the ApplicationArguments type
   var p = new FluentCommandLineParser<ApplicationArguments>();

   // specify which property the value will be assigned too.
   p.Setup(arg => arg.RecordId)
    .As('r', "record") // define the short and long option name
    .Required(); // using the standard fluent Api to declare this Option as required.

   p.Setup(arg => arg.NewValue)
    .As('v', "value")
    .Required();

   p.Setup(arg => arg.Silent)
    .As('s', "silent")
    .SetDefault(false); // use the standard fluent Api to define a default value if non is specified in the arguments

   var result = p.Parse(args);

   if(result.HasErrors == false)
   {
      // use the instantiated ApplicationArguments object from the Object property on the parser.
      application.Run(p.Object);
   }
}

You can also use the non-generic Fluent Command Line Parser to capture values without creating a container class.

static void Main(string[] args)
{
  var p = new FluentCommandLineParser();

  p.Setup<int>('r')
   .Callback(record => RecordID = record)
   .Required();

  p.Setup<string>('v')
   .Callback(value => NewValue = value)
   .Required();

  p.Setup<bool>('s', "silent")
   .Callback(silent => InSilentMode = silent)
   .SetDefault(false);

  p.Parse(args);
}

Parser Option Methods

.Setup<int>('r') Setup an option using a short name,

.Setup<int>('r', "record") or short and long name.

.Required() Indicate the option is required and an error should be raised if it is not provided.

.Callback(val => Value = val) Provide a delegate to call after the option has been parsed

.SetDefault(int.MaxValue) Define a default value if the option was not specified in the args

.WithDescription("Execute operation in silent mode without feedback") Specify a help description for the option

Parsing To Collections

Many arguments can be collected as part of a list. Types supported are string, int32, int64, double, bool, Uri, DateTime and Enum

For example arguments such as

--filenames C:\file1.txt C:\file2.txt "C:\other file.txt"

can be automatically parsed to a List<string> using

static void Main(string[] args)
{
   var p = new FluentCommandLineParser();

   var filenames = new List<string>();

   p.Setup<List<string>>('f', "filenames")
    .Callback(items => filenames = items);

   p.Parse(args);

   Console.WriteLine("Input file names:");

   foreach (var filename in filenames)
   {
      Console.WriteLine(filename);
   }
}

output:

Input file names
C:\file1.txt
C:\file2.txt
C:\other file.txt

Enum support

Since v1.2.3 enum types are now supported.

[Flags]
enum Direction
{
	North = 1,
	East = 2,
	South = 4,
	West = 8,
}
p.Setup<Direction>("direction")
 .Callback(d => direction = d);

To specify 'East' direction either the text can be provided or the enum integer.

dosomething.exe --direction East
dosomething.exe --direction 2

You can also collect multiple Enum values into a List<TEnum>

List<Direction> direction;

p.Setup<List<Direction>>('d', "direction")
 .Callback(d => direction = d);

For example, specifiying 'South' and 'East' values

dosomething.exe --direction South East
dosomething.exe --direction 4 2

Since v1.4 Enum Flags are also supported

Direction direction;

p.Setup<Direction>("direction")
 .Callback(d => direction = d);

p.Parse(args);

Assert.IsFalse(direction.HasFlag(Direction.North));
Assert.IsTrue(direction.HasFlag(Direction.East));
Assert.IsTrue(direction.HasFlag(Direction.South));
Assert.IsFalse(direction.HasFlag(Direction.West));

And the generic FluentCommandLineParser<T> (previously known as FluentCommandLineBuilder) also supports enums.

public class Args
{
   public Direction Direction { get;set; }
   public List<Direction> Directions { get;set; }
}
var p = new FluentCommandLineParser<Args>();

p.Setup(args => args.Direction)
 .As('d', "direction");

p.Setup(args => args.Directions)
 .As("directions");

From v1.5 nullable enums are now supported.

Help Screen

You can setup any help arguments, such as -? or --help to print all parameters which have been setup, along with their descriptions to the console by using SetupHelp(params string[]).

For example:

// sets up the parser to execute the callback when -? or --help is detected
parser.SetupHelp("?", "help")
      .Callback(text => Console.WriteLine(text));

Since v1.4.1 you can also choose to display the formatted help screen text manually, so that you can display it under other circumstances.

For example:

var parser = new FluentCommandLineParser<Args>();
	
parser.SetupHelp("?", "help")
      .Callback(text => Console.WriteLine(text));
	
// triggers the SetupHelp Callback which writes the text to the console
parser.HelpOption.ShowHelp(parser.Options);

Supported Syntax

[-|--|/][switch_name][=|:| ][value]

Supports boolean names

example.exe -s  // enable
example.exe -s- // disabled
example.exe -s+ // enable

Supports combined (grouped) options

example.exe -xyz  // enable option x, y and z
example.exe -xyz- // disable option x, y and z
example.exe -xyz+ // enable option x, y and z

Development

Please feel free to provide any feedback on feature support or the Api itself.

If you would like to contribute, you may do so to the develop branch. Please contact me first if doing large scale changes.

fluent-command-line-parser's People

Contributors

alexruzzarin avatar aspark avatar do0om avatar kakashif avatar kdelmonte avatar kjgorman avatar lazytarget avatar mudrz avatar pchalamet avatar pragmatrix avatar rdcarp avatar siywilliams avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fluent-command-line-parser's Issues

DateTime parsing problem

I am getting the following error when passing a valid datetime to a datetime argument:

 my.exe --start-date "03/06/2014 10:00:00 AM" --end-date "03/06/2014 10:01:00 AM" 
Option '--start-date' parse error: could not parse '03/06/2014 10:00:00 AM' to 'System.DateTime'.
Option '--end-date' parse error: could not parse '03/06/2014 10:01:00 AM' to 'System.DateTime'.
==> \n use --help to see the manual

Does not recognize files that start with a slash, e.g. "/var/log/test.txt"

When setting up for retrieving file names (p.Setup<List>('f', "files")), the resulting parser does not recognize file names that start with a slash, such as "/var/log/test.txt" or "/Users/fclp/test.txt".
I suppose this is because the slash is interpreted as an option.
However, I did not find anything that lets me disable "/" as option trigger.
Note that such file names are standard on Linux / Mac environments.

Needs to handle free arguments.

I'd like to extract free arguments from the command line, e.g. arguments without an option like MyConsoleApp.exe --opt1 opt1value Filename.txt. Right now it seems that Filename.txt is ignored and can not be extracted from CommandLineParserResult.

Is this planned?

Conflict between short option and long option - always picks short option

Hi

I've got two options setup, one of which has a short code, which matches the first letter of the other long option.

bool option1Matched = false;
bool option2Matched = false;

p.Setup<string>('t', "option1").Callback(t => option1Matched = true);
p.Setup<string>("test2").Callback(t => option2Matched = true);

p.Parse(new[] {"-test2","value"});

Assert.IsFalse(option1Matched, "option1Matched should be false");
Assert.IsTrue(option2Matched, "option2Matched should be true");

The option passed in is "test2" but the "t" setup option is being called. Surely in this instance the most exact match (the second "test2" option) should be matched?

fluent builder to populate specific type used to hold parsed values

There seems to be two common types of command line parser, the type that parse and store the values ready to be retrieved by some key/value pair, and another that populates an already defined arguments class with the parsed values (usually using ugly attributes). The second type does have an advantage in some cases because it removes the step required to pull the parsed values from the key/value pair storage into a object ready to plug into the system.

Although in early stages, the FluentCommandLineBuilder can bridge that gap by populating a specified type with parsed values whilst still using the FluentCommandLineParser API.

For example, if our system parses arguments into a class such as the following

public class ApplicationArguments
{
   public int RecordId { get; set; }
   public bool Silent { get; set; }
   public string NewValue { get; set; }
}

we can parse strongly types values directly to a build instance of the type using the FluentCommandLineBuilder

var b = new FluentCommandLineBuilder<ApplicationArguments>();

b.Setup(arg => arg.RecordId)
  .As('r', "record")
  .Required();

b.Setup(arg => arg.NewValue)
  .As('v', "value")
  .Required();

b.Setup(arg => arg.Silent)
  .As('s', "silent")
  .SetDefault(false);

var result = b.Parse(args);

if(result.HasErrors == false)
{
   application.Run(b.Object);
}

By providing the additional FluentCommandLineBuilder the FluentCommandLineParser can be used in either style.

Include option prefix in CommandLineParserResult.AdditionalOptionsFound

When requesting AdditionalOptionsFound for the purposes of forwarding to a secondary application, it becomes important to know if an option was lead with a -, --, or /.
I think the easiest (and least breaking) way to implement this would be to add a new property, AdditionalOptionsRaw, which is an IEnumerable<string> that contains the raw unparsed arguments for arguments that couldn't be set up.

Support 0 and 1 for bool false and true

There are currently a few ways of specifying boolean arguments, but I would one more. I think it is reasonable to be able to pass 0 for false and 1 for true. Powershell commands normally support 0 or 1 anywhere they would accept $false / $true (which are currently supported).

Mutually exclusive args

Does FCLP support mutually exclusive args? For example : if optional args --cert is specified, then --certkey is required, otherwise both are optionals.

Another validation question

I've written a validation extension method using ICommandLineOptionFluent as the extensions key parameter, the method signature is as follows:

    public static void Validate<T>(this ICommandLineOptionFluent<T> value, Predicate<T> validate)
    {
        ...
        ...
        ...
    }

My question is how can I get the value to pass to the predicate, currently I see no way of doing this rendering the extension pointless. I was hoping to write something which I could contribute back.

As as an example of how I pictured this working:

        fluentCommandLineParser
            .Setup(arg => arg.Endpoints)
            .As('e', "endpoint")
            .Required()
            .Validate(addresses => addresses.All(address => address.IsAddress()));

Any advice?

Thanks,
Lee.

Quotes not properly handled

It appears that quotes are not properly handled with the arguments. For instance, if one of the arguments is a path such as "c:\directory to my files", which needs to be in quotes, then the parser will not assign a value. I'm using the Generic Fluent Command Line Parser.

I can confirm that if I manually strip out the quotes in the beginning and in the end that properties are assigned correctly. I started to go through the code to find the source of the problem, but I am on a bit of a tight deadline to get out some command line tools. Once I get past the deadline, I'll take a look and see if I can spot the problem.

Thanks for making a nice tool.

back slash at end of string option doesnt work

if i have this:

p.Setup(arg => arg.Directory)
.As("Dir")
.WithDescription("\tDirectory to look for hives (recursively). --Hive or --Dir is required.");

and then call the program like this:

foo.exe --dir "C:\temp\bar" --sk [veris

things work, but if i do this

foo.exe --dir "C:\temp\bar" --sk [veris

i get this error

Option '--dir' parse error: could not parse 'C:\temp\bar" --sk [veris' to 'System.String'.

seems that last back slash is causing issues. any work around?

handle of empty arguments

Empty arguments are handled sometimes in a different manner. They could, for example, return an error to the caller, or automatically print the help text.

It would be nice to expose a fluent way of defining the behaviour when empty args are encountered.

One option would be to setup behaviour in a simular way to help, such as through a callback:

parser.SetupEmpty(text => Console.WriteLine(text));

The consumer could execute a custom action here. If the callback was not used to throw an error it would need us to include a way to check for empty args after the parse operation so the application could be exited cleanly such as:

var result = parser.Parse(args);

if(result.WasEmptyArgs)
{
   return;
}

Support long/int64

There is no support for long types. There are cases where there is a need to parse something longer than int.max.

Problem with single dashes and longOption

Parsing an option using a single dash results in errors.
See examples below.

This gives a problem:
Util.exe -dns "a.b.c" -ip "10.23" -num 23

This works ok:
Util.exe -d "a.b.c" -i "10.23" -n 23
Util.exe /dns "a.b.c" /ip "1.2.3.4" /num 23
Util.exe --dns "a.b.c" --ip "1.2.3.4" --num 23

class Options
{
public bool ShowHelp { get; set; } = false;
public string Dns { get; set; }
public string Ip { get; set; }

    public int Num { get; set; }

    public static Options ParseArguments(string[] args)
    {
        var parser = new FluentCommandLineParser<Options>();
        parser.Setup<string>(o => o.Dns)
            .As('d',"dns")
            .WithDescription("DNS name");
        parser.Setup(o => o.Ip)
            .As('i',"ip")
           .WithDescription("IP address");
        parser.Setup(o => o.Num)
            .As('n', "num")
            .WithDescription("Number");

        parser.SetupHelp("?", "h", "help")
            .Callback(() => { parser.Object.ShowHelp = true; });

        var result = parser.Parse(args);
        return parser.Object;
    }
}

Target .net 5 Core

I'd love to use this, but most of my code targets aspnet 5 core only...

can you target the new stack?

support parsing directly to collections

for example the consumer may want to capture a number of different filenames to process.

--filenames file1.txt file2.txt file2.txt

It would be a good feature to parse the 3 text files into a list of strings. If --filenames has no values an empty list could be returned, or error thrown if it is required.

SetupHelp workflow

Hi,

When you have to call help, the parser: ICommandLineParserResult result = parser.Parse(args); doesn't parse args at all.
It'd nice if we can have all arguments parsed even if we the property HelpCalled = true; because we might have a use another argument to do something else. :)

support validation

The Api lends itself nicely to some fluent validation. The failures would be returned as part of the parse result object.

The fluent Api could be provided by a set of extenstion methods that hang off the WithValidation() result, for example

parser.Setup<int>("p", "percent").Required().WithValidation()
      .GreaterOrEqualTo(0)
      .LessOrEqualTo(100);

Add version argument capability

Most command line applications must support information beyond just the help of the arguments. For example, the ability to get the version of the executable. This is typically done as follows:
[-v | --version], just like the help is done with [-h | -? | --help]

I need a way to specify a argument switch such as -v and --version where there isn't any value and if this is the argument, bypasses all the required arguments and processes the callback on the parameter.

If this exists, I have not found a way to do it given the documentation. A last ditch effort is to add it as part of the showhelp header and my users have to use the help to get the version even if it prints all the other information. I checked in the result of parse or even in helpoption, to see if I could see what options were given and if -v/--version was one of them, just print version info, but couldn't find a way for that either.

Thank you for the library...!

Best way to quit when help is requested

I'm using generic FluentCommandLineParser like this:

public class Arguments
{
    public string InputFile { get; set; };

    public static Arguments Parse(string[] args)
    {
        var p = new FluentCommandLineParser<Arguments>();
        p.SetupHelp("h", "help", "?").Callback(s => Console.WriteLine(s));
        p.Setup(job => job.InputFile).As('i', "inputFile").WithDescription("Input file");
        var result = p.Parse(args);
        return p?.Object;
    }
}
private static void Main(string[] args)
{
    var arguments = Arguments.Parse(args);
    // If help 
    ...

And i'd need to quit if help was requested.

I know I can add a property bool HelpNeeded in my Arguments class and assign it either in SetupHelp Callback or using result.HelpCalled. But I think I can miss something.

Do you have a better option?

Feature proposal: Provide a way to specify arguments object factory method

In version 1.4.3, FluentCommandLineParser<TBuildType> requires that TBuildType provides public parameterless constructor, using new() generic parameter constraint. Will be nice to have a way to use arguments object without public parameterless constructor. For instance, by introducing FluentCommandLineParser<TBuildType> constructor overload, which accepts Action<TBuildType> factory method. It can be used to better argument object incapsulation, by prohibiting its creation outside of argument object factory method. For example:

internal class StartupArguments
{
    public bool Argument1 { get; private set; }
    public bool Argument2 { get; private set; }
    public bool HelpCalled { get; set; }

    // I can't do it private now :(
    private StartupArguments()
    {
    }

    public static StartupArguments Parse(string[] args)
    {
        // Just creates arguments object
        var parser = new FluentCommandLineParser<StartupArguments>(() => new StartupArguments());

        // Setup here

        var parsingResult = parser.Parse(args);

        parser.Object.HelpCalled = parsingResult.HelpCalled;

        return parser.Object;
    }
}

Lovely lib, mate ๐Ÿ‘

Bug: longName doesn't work if shortName not supplied

Fails to find option -engine="c:\engine.txt":

cmdLine.Setup<string>("engine").Required().Callback(value => Engine = value);

Finds option -engine="c:\engine.txt":

cmdLine.Setup<string>('e', "engine").Required().Callback(value => Engine = value);

Object produced by generic FluentCommandLineParser contains default values, instead of parsed values when initialized with a struct

Greetings!

Thank you very much for providing this library! I recently downloaded it from Nuget, and was able to get it working with the non-generic parser. Very straight forward - your documentation on github was helpful.

I had some trouble with the generic Fluent Command Line Parser, though - the object the parser creates did not contain the parsed values, instead its values were initialized with default values (strings and enums were null, bools were false, etc.).

I was doing this:
var parser = new FluentCommandLineParser();
When ApplicationArguments is a struct, parser.Object does not contain the parsed values (as described above).

When ApplicationArguments is a class, parser.Object contains parsed values. I'm not sure why structs don't work yet, but wanted to give you a heads up.

I'm guessing something like this may help restrict users to only using class arg containers (in FluentCommandLineParserT.cs)?
public class FluentCommandLineParser : IFluentCommandLineParser where TBuildType : class, new()

Also, as an FYI, I'm not getting errors, empty args, help, unmatched options, or additional options found. Let me know if you need any other detail - take care.

Supported Syntax: space char is not supported

Based on the docs in the README the space character should work for options in the format:

foo.exe -n 123

However only : and = work, using a space results in a parse error.

From the docs:

Supported Syntax

[-|--|/][switch_name][=|:| ][value]

Feature Request: Optionally required

I'd like to have an option optionally required if another parameter is not specified or vice versa.
For example, I have a sftp password parameter that is required unless I specified the local file option in which case I don't want it required.

Something like RequiredWhen(Func requiredFunc) on the fluent interface?

Help default output syntax not standard.. make extensible or change?

Output of --help:

p:Platform MyDescription
s:Syntax Syntax for the state machine

is not really helpful. It does not tell the user that he has to actually pass via - or --
And the description should be on the next line indented, this way you would also avoid the weird look because currently you just do a specific amount of spaces/tabs and if the arg string length is different, the descriptions all start at a different indention level.
And the help should be displayed by default if no args were parsed.

Desired output of --help

-p --platform (Required)
     MyDescription
-s --syntax 
     Syntax for the state machine

So this is the kind of format you expect on linux tools and I think it would be very readable.

Support synonyms

It would be good to support synonyms for long options (say, --int-ip and --internal-ip referring to the same option in different ways). Think this would probably need some changes to the formatter and parser.

It could be implemented with two extra setup overloads:

Setup(params string long)
Setup(char short, params string long)

Get Help text apart from SetupHelp callback

I need a way to get help text (same text as sent to Callback) but appart from Callback.

I some case, help is not asked by caller but some parameters failed a second stage validation (something like "Is the file designated by the parameter exists") and I want to Print error message followed by standard usage.

How to find out with option was triggered

I'm wondering if there's an elegant way of knowing which option has been set, so that a proper method can be called. For example:

        p.Setup<List<string>>("a", "addproducts")                      
            .Callback(items => arguments.NewNumbers = items);
        p.Setup<List<string>>("r", "removeproducts")                   
            .Callback(items => arguments.RemoveNumbers = items);
        p.Parse(args);

        if (arguments.NewNumbers != null)
            return ConfirmProductNumbers(arguments);
        else if (arguments.RemoveNumbers != null)
            return ConfirmProductNumbers(arguments);

Thanks for your time.

Get rid of the short options

There is no point to making any distinctions between short and long. A switch is a switch is a switch.

  1. -|--|/ are reserved switch tokens
  2. Option name(s) can be any non-spaced string.
  3. Let me have any number of options that target a value.

I should be able to do this.

var daddyIssues = new[] {"who","is","Your","Daddy","?" };
var p = new FluentCommandLineParser(false); // case insensitive, I would like to hard code this!
p.Setup(daddyIssues)
.CallBack(p=>Daddy=p)
.SetDefault("The mailman");

I should be able to then do this assuming not case sensitive
myapp.exe -Who or --Who or /who
myapp.exe --? or -? or /?

Working fork with long and short names removed if you want to verify and pull. Followed your coding style.
Unit tests completely broken, but I'll get to that.
https://github.com/ghstahl/fluent-command-line-parser

Also, I don't see the point of having caseSensitive options. All it does is confuse users. Option arguments preserve case, but that isn't this.

How to display help screen

Can you please provide an example on how to display a help screen that list all parameters and their purpose?

Command with parameter

Hello,
I was wondering if fclp has got a command concept with per-command parameters.
Something like this:

SetupCommand("create")
.WithParam("initialUrl")
.Required()

SetupCommand("restore")
.WithParam("fromFile")
.Required()

And then use it in this way

myApp.exe create --initialUrl http://www.google.it
myApp.exe restore --fromFile C:\data.json

Parser exits without error but does do callbacks; can't step into call backs VS15

I thought this was a wonderful idea. Only if it worked.
I tested this both with and without an Argument class.
I want to short circuit the GUI in a WPF project and run it as a CLI or a GUI project.

Downloaded with NuGet; no source code yet. I would like to get some work done

   public class MyApplicationArguments
        {
        public Boolean CLI
            {
            get; set;
            }
        public bool NoGUI
            {
            get; set;
            }
        public String PROGRAM
            {
            get;
            set;
            }
        public String PATH
            {
            get;
            set;
            }
        };
    static Boolean VerboseDebug = false;// something to switch on and off
    static MyApplicationArguments AA = new MyApplicationArguments ();// make static to be safe
    public MainWindow ( )

String CmdLine = Environment . CommandLine;
String [ ] CmdArgs = Environment . GetCommandLineArgs ( );

        //var p = new FluentCommandLineParser <MyApplicationArguments>( );
        var p = new FluentCommandLineParser ( );

        //p . Setup ( arg => arg . CLI ).As( 'c' , @"CLI" ).SetDefault( true );
        p . Setup<Boolean> ( 'c' , @"CLI" ) . Callback ( arg => AA . CLI = arg ) . SetDefault ( true );

        //p . Setup<Boolean> ( 'g' , @"NoGUI" ) . Callback ( arg => AA . NoGUI = arg ) . SetDefault ( true );

        //p . Setup<String> ( 'p' , @"PROGRAM" ) . Callback ( arg => AA . PROGRAM = arg ) . SetDefault ( "Excel.exe" );

        //p . Setup<String> ( 'P' , @"PATH" ) . Callback ( arg => AA . PATH = arg ) . SetDefault ( "blurble" );

        var result = p . Parse (  CmdArgs);

        if ( result . HasErrors == true )
            {
            return;
            }

        if ( AA.NoGUI )// never touched by parser in callback no error
            {
            String Arg = AA . PROGRAM;// never touched by parser in callback no error
            FindInPathAndExecute ( Arg );
            return;
            }`

parameters with argument should throw error if arment is omitted

If my parameter requires an argument, I would like an error to be thrown if that argument is not supplied.

I tried detecting this in the callback, but the callback never gets called if the argument is not supplied. Essentially it treats it as if the parameter was never supplied.

i.e.,

If the 't' parameter requires a numeric value and should be called like: myapp.exe -t 5, but
myapp.exe -t
is the same as
myapp.exe.

This can lead to some unexpected behavior.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.