Giter Club home page Giter Club logo

manyconsole's Introduction

ManyConsole

Available on Nuget: http://nuget.org/List/Packages/ManyConsole

Thanks to Daniel González for providing some additional documentation: http://dgondotnet.blogspot.dk/2013/08/my-last-console-application-manyconsole.html

Mono.Options (formerly NDesk.Options) is a great library for processing command-line parameters. ManyConsole extends Mono.Options to allow building console applications that support separate commands.

If you are not familiar with Mono.Options, you should start by using that: https://components.xamarin.com/gettingstarted/mono.options?version=5.3.0. Add ManyConsole when you feel the urge to differentiate commands (you'll still need the Mono.Options usage).

ManyConsole provides a console interface for the user to list available commands, call and get help for each.

To use ManyConsole:

Quick Start Guide

Run this from NuGet Package Management Console:

Install-Package ManyConsole

Drop this in to automatically load all of the commands that we'll create next:

public class Program
{
    public static int Main(string[] args)
    {
        var commands = GetCommands();

        return ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);
    }

    public static IEnumerable<ConsoleCommand> GetCommands()
    {
        return ConsoleCommandDispatcher.FindCommandsInSameAssemblyAs(typeof(Program));
    }
}

Create a command with one optional, one required and a short and long description:

public class PrintFileCommand : ConsoleCommand
{
    private const int Success = 0;
    private const int Failure = 2;

    public string FileLocation { get; set; }
    public bool StripCommaCharacter { get; set; }

    public PrintFileCommand()
    {
        // Register the actual command with a simple (optional) description.
        IsCommand("PrintFile", "Quick print utility.");
            
        // Add a longer description for the help on that specific command.
        HasLongDescription("This can be used to quickly read a file's contents " +
        "while optionally stripping out the ',' character.");
            
        // Required options/flags, append '=' to obtain the required value.
        HasRequiredOption("f|file=", "The full path of the file.", p => FileLocation = p);

        // Optional options/flags, append ':' to obtain an optional value, or null if not specified.
        HasOption("s|strip:", "Strips ',' from the file before writing to output.",
            t => StripCommaCharacter = t == null ? true : Convert.ToBoolean(t));
    }

    public override int Run(string[] remainingArguments)
    {
        try
        {
            var fileContents = File.ReadAllText(FileLocation);

            if (StripCommaCharacter)
                fileContents = fileContents.Replace(",", string.Empty);

            Console.Out.WriteLine(fileContents);

            return Success;
        }
        catch (Exception ex)
        {
            Console.Error.WriteLine(ex.Message);
            Console.Error.WriteLine(ex.StackTrace);

            return Failure;
        }
    }
}

Ok, now when you run it, it should work:

>ManyConsoleDocumentation PrintFile -f "C:\HelloWorld.txt"

Extra parameters specified: C:\HelloWorld.txt

'PrintFile' - Quick print utility.

This can be used to quickly read a file's contents while optionally stripping out the ',' character.

Expected usage: ManyConsoleDocumentation.exe PrintFile <options>
<options> available:
  -f, --file                 The full path of the file.
  -s, --strip                Strips ',' from the file before writing to
                               output.

It doesn't work and thinks we specified an invalid parameter. This is because options that are followed by a parameter must have an '=' symbol, so update the two commands with f|file= and s|strip=, it should now work:

>ManyConsoleDocumentation PrintFile -f "C:\HelloWorld.txt"

Executing PrintFile (Quick print utility.):
    FileLocation : C:\HelloWorld.txt
    StripCommaCharacter : False

Hello, world!

>ManyConsoleDocumentation PrintFile -f "C:\HelloWorld.txt" -s true

Executing PrintFile (Quick print utility.):
    FileLocation : C:\HelloWorld.txt
    StripCommaCharacter : True

Hello world!

Now you can easily supply multiple commands with their own set of unique arguments:

public class EchoCommand : ConsoleCommand
{
    public string ToEcho { get; set; }

    public EchoCommand()
    {
        IsCommand("Echo", "Echo's text");
        HasRequiredOption("t|text=", "The text to echo back.", t => ToEcho = t);
    }

    public override int Run(string[] remainingArguments)
    {
        Console.Out.WriteLine(ToEcho);

        return 0;
    }
}

Here's how the help looks, plus help for our two commands:

>ManyConsoleDocumentation help

Available commands are:

    Echo        - Echo's text
    PrintFile   - Quick print utility.

    help <name> - For help with one of the above commands

>ManyConsoleDocumentation help PrintFile

'PrintFile' - Quick print utility.

This can be used to quickly read a file's contents while optionally stripping out the ',' character.

Expected usage: ManyConsoleDocumentation.exe PrintFile <options>
<options> available:
  -f, --file=VALUE           The full path of the file.
  -s, --strip=VALUE          Strips ',' from the file before writing to
                               output.

>ManyConsoleDocumentation help Echo

'Echo' - Echo's text

Expected usage: ManyConsoleDocumentation.exe Echo <options>
<options> available:
  -t, --text=VALUE           The text to echo back.

Building the solution, running tests, and packaging the nuget file

  • You will probably need to download the old copy of .NET this was built against: https://dotnet.microsoft.com/en-us/download/dotnet/2.2 (the last I built was with SDK 2.2.207)
  • From a powershell window, run psake.ps1
  • This will run the tasks defined in default.ps1, building the project, running the tests and putting together a nupkg file.
  • The version number in default.ps1 needs to be updated when building a new nupkg file for release.

manyconsole's People

Contributors

angularsen avatar bfriesen avatar chuseman avatar david-durrleman avatar fschwiet avatar hivanov avatar roadrunner67 avatar rohancragg avatar royhaddad avatar shift-evgeny 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

manyconsole's Issues

How do I handle an OptionException?

If a user doesn't enter a value for a required option the application throws the below. I tried wrapping the call to DispatchCommand() with a try catch, but it doesn't catch anything.

Exception encountered: NDesk.Options.OptionException: Missing required value for option '/a'.
at NDesk.Options.OptionValueCollection.AssertValid(Int32 index)
at NDesk.Options.OptionSet.<>c__CompilerGenerated0.c__4[T](OptionValueCollection v)
at NDesk.Options.OptionSet.ActionOption.OnParseComplete(OptionContext c)
at NDesk.Options.Option.Invoke(OptionContext c)
at NDesk.Options.OptionSet.Parse(IEnumerable1 arguments) at ManyConsole.ConsoleCommandDispatcher.DispatchCommand(IEnumerable1 commands, String[] arguments, TextWriter consoleOut) in c:\src\ManyConsole\Ma
nyConsole\ConsoleCommandDispatcher.cs:line 56

try
{
    return ConsoleCommandDispatcher.DispatchCommand(commands, args, Console.Out);
}
catch (Exception e) // this doesn't catch anything
{
    Console.Write("Exception happened!!!!!");
    return _errorCode;
}

'help' without command throws unhandled exception

Hi,

I've been using ManyConsole for my project - it's really good, thanks!

The new 'help' feature is a great idea - but it would be great if calling 'help' without a command gave the same list of commands as the 'No arguments specified' output.

At the moment it throws an unhandled exception:

$ dim help

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at ManyConsole.Internal.ConsoleHelp.ShowCommandHelp(ConsoleCommand selectedCommand, TextWriter console) in c:\src\ManyConsole\ManyConsole\Internal\ConsoleHelp.cs:line
 31
   at ManyConsole.ConsoleCommandDispatcher.DispatchCommand(IEnumerable`1 commands, String[] arguments, TextWriter consoleOut) in c:\src\ManyConsole\ManyConsole\ConsoleCommandDispatcher.cs:line 81
   at Dim.Program.Main(String[] args) in c:\Users\Phil\Projects\Dim\src\Program.cs:line 19

Again, thanks for the great tool.

ConsoleModeCommand limited to 256 chars

We've recently started using ManyConsole and it's saved us writing the same boiler plate code over and over again.

One small issue that we've encountered is that when in console mode it appears that the command is limited to 256 chars, is this by design or is the some configuration setting that can be changed ?

Main example shows obsolete usage technique

The main example is at introduced on the main page (https://github.com/fschwiet/ManyConsole)

The example itself is inside https://github.com/fschwiet/ManyConsole/blob/master/SampleConsole/Program.cs and uses it as

new ConsoleModeCommand(GetCommands);

This flags the warning Its preferred to override methods on ConsoleModeCommand and use the shorter constructor. in ManyConsole.dll v0.4.2.16 due to

[Obsolete("Its preferred to override methods on ConsoleModeCommand and use the shorter constructor.")]
public ConsoleModeCommand(Func<IEnumerable<ConsoleCommand>> commandSource, <snip>)

inside the ConsoleModeCommand class

disabling trace output

Is there a reason that the tracing output of a command cannot be disabled? It's currently a private property instead of public/protected?

Anyway I short-circuited the execution to prevent the logging using:

public override int? OverrideAfterHandlingArgumentsBeforeRun(string[] remainingArguments)
{
    return this.Run(remainingArguments);
}

HasRequiredOption only handles string parameters, not other types

When constructing a command, I see that I can create commands for different basic types like int with this.HasOption. However, this.HasRequiredOption does not following the same syntax and only enforces string:

public class FooCommand : ConsoleCommand
{
int a;
int b;

    public FooCommand()
    {
        this.IsCommand("foo", "Show int processing issues");
        this.HasOption("a", "Works fine", (int v) => a = v);
        this.HasRequiredOption("b", "Compiler vomits about it not being a string", (int v) => b = v);
    }
}
What I pulled from nuget was: "ManyConsole" version="0.4.2.8" targetFramework="net35" "NDesk.Options" version="0.2.1" targetFramework="net35"

I'm using Visual Studio 2010 SP1.

No longer .NET 4.5 compatible but not indicated in nuspec

If the purpose was to break the package so that it is no longer .NET45 compatible, I would suggest updating the nuspec/release notes to include this information.

The current release notes "updated to .NET 4.6.1 or 4.5 or something" make it seem as if both frameworks are included in the package, when only net461 is. You can denote this in the nuspec with target frameworks.

I was looking forward to the updates, but can't use anything over 4.5 in my application. Nuget allowed me to install the package and then when I built it I got Framework mismatch errors. Not a big deal, I can continue to use the old version.

Based on the commit history and the latest main branch merge, there is nothing actually .NET 46 dependent that was added into this library. A possible solution would also be adding a NET45-specific csproj/sln (like other libraries do) and including both assemblies (targeting different versions) in the package (under \lib\net45, \lib\net461, etc)

Add interactive mode

It would be nice to run the command from Visual Studio
for example

            while (true)
            {
                var args = new List<string>();
                Console.Write("> ");
                var userCommands = Console.ReadLine();
                if (userCommands == "e" || userCommands == null)
                {
                    break;
                }
                args.AddRange(userCommands.Split(' '));
                if (args[0] == "help")
                {
                    ConsoleCommandDispatcher.DispatchCommand(_commands, args.ToArray(), _writer);
                    continue;
                }

                var command = _commands.FirstOrDefault(x => x.Command == args[0]);
                if (command == null)
                {
                    continue;
                }

                ConsoleHelp.ShowCommandHelp(command, _writer, true);

                var actualArgs = new List<string> { command.Command };
                foreach (var actualOption in command.GetActualOptions())
                {
                    Console.WriteLine(actualOption.Description + (actualOption.OptionValueType == OptionValueType.Required ? "*:" : ":"));
                    var userInput = Console.ReadLine();
                    actualArgs.Add($"--{actualOption.GetNames().Last()}={userInput}");
                }                
                ConsoleCommandDispatcher.DispatchCommand(_commands, actualArgs.ToArray(), _writer);
            }

This is just a sample as additional options are not supported

Xml document

Please add xml document into the NuGet package, it's very important for IntelliSense of IDE.

No good way of handling boolean switches.

If I just use the following in the code (taken from the example in this repo, as a matter of fact):

this.HasOption("b|booleanOption", "Boolean flag option", b => BooleanOption = true);

then, at the command line, one cannot specify just -b because it complains of a missing value. And one can specify -b true or -b false or -b maybe and it would behave the same!

Minor suggestion: Make an overload of ConsoleCommandDispatcher.DispatchCommand that accept a ReadOnlyCollection<string> on the arguments param

Use case:
An GUI app written on Visual Basic language with the application framework enabled.
The argument of the Application Startup event returns the command line arguments on a ReadOnlyCollection<string> (see https://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.startup(v=vs.110).aspx)
The My.Application.CommandLineArgs is also return a ReadOnlyCollection<string> (see https://msdn.microsoft.com/en-us/library/z2d603cy(v=vs.90).aspx)
There is no direct way to convert that collection to an array. Need to iterate it and copy or use Linq ToArray() extension method (the same thing).
But the array can be converted to ReadOnlyCollection<T> just calling the .AsReadOnly() and is a O(1) operation (see https://msdn.microsoft.com/en-us/library/53kysx7b(v=vs.110).aspx).
Internally you can talk to an IList<string> which can hold an string[] or an ReadOnlyCollection<string> And everybody happy :)

Add a strong name

ManyConsole.dll isn't signed so it doesn't have a strong name.

Because of this it makes it more difficult to use in projects that have strong names, they have to decompile it and recompile it using a key. It also gets more complicated if it's using nuget to fetch it.

You would be doing people a favor by signing it before you package it.

Handling Arguments to commands

How can I specify something like

git config key value

Example

vendor save bill instead of vendor save --vendor bill

I know how to do the latter but not the former.

Allow Extra Parameters for ConsoleModeCommand

I'd like to allow the user to optionally supply extra "configuration" parameters when specifying run-console

i.e.

MyUtil run-console -d:09/15/12

I'm trying to use a singleton for tool wide configuration settings so the user doesn't have to specify for each command. Ideally, I'd like to grab that date on startup and use it for each subsequent command.

Right now if I do that I get "Extra parameters specified"

  1. Can I derive a new class from ConsoleModeCommand and implement the extra parameters?
  2. Can I just tweak the existing to say "ignore extra parameters".

Right now I'm just trying to process the extra parameter myself.

thanks for any help you can provide.

Multiple excluding commands

I was wondering if there is an option to create multiple excluding, like incompatible commands like

console.exe -ACommand value1 -AnotherCommand value2

and display an error like

ACommand and AnotherCommand are not compatible. You should choose one or the other.

Or a way to check in the ACommand class and/or the AnotherCommand class if the other was already executed.

Parsing Text and Multiple Parameters

Command parameters are not parsed entirely as I would expect and I do not see anything in the documentation to point me to a solution at this point.

Comments in the source of ManyConsole suggest that the behavior for parsing parameters should be as such:

// this command
my-command --integer 1 --string "some long text value" --collection param1 param2 param3

// should evaluate to
--integer == 1
--string == "some long text value"
--collection = ["param1", "param2", "param3"]

http://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs.aspx

Instead, the option --string ignores any quote and parses the space delimiter.

// actual parameterization
--string == "some
--collection == param1

// then everything else falls into a generic container:
AdditionalArguments == long, text, value", param2, param3

How can several values be collected in one parameter call?

// In the derived ConsoleCommand constructor I want to avoid something like:
my-command --string some --string long --string text --string value

// and then doing:
HasOption<string>("s|string=", v => StringList.Add(v));

// finally:
var stringValue = string.Join(" ", StringList);

I could parse out the remaining arguments after all single value command options are captured, but it will be difficult to come up with a constant number of parameters for the "HasAdditionalArguments" override.

Here's a sample of what I'm doing:

public class TestCommand : ConsoleCommand {

        public TestCommand() {
            IsCommand("my-command");

            StringList = new List<string>();
            HasOption("s|string=", "captures a text parameter", s => StringList.Add(s));
        }

        public List<string> StringList; 
        public override int Run(string[] remainingArguments) {
            var stringValue = string.Join(" ", StringList);

            System.Console.WriteLine("Received input: " + stringValue);
            return 0;
        }
    }

Let me know if I'm missing any existing configuration here. Perhaps I can override the argument delimiter per option?

REPL mode?

I'm creating a REPL (Read-Eval-Print Loop) and using ManyConsole to handle the commands for me. For the most part this works beautifully:

public static void Main(string[] args)
{
    var commands = GetCommands();
    while (true)
    {
        Console.Write(">");
        var currentCommand = Console.ReadLine();
        
        try
        {
            var returnValue = ConsoleCommandDispatcher.DispatchCommand(commands, currentCommand.Split(' '), Console.Out);
        }
        catch(Exception ex)
        {
            Console.WriteLine("Command threw exception:");
            Console.WriteLine(ex.Message);
        }
}

Now I can interact with it as you'd expect:

>help

Available commands are:

    Exit        - Exit REPL
    Test        - Test Command

    help <name> - For help with one of the above commands

>Test

Hello, World!
>Exit

The problem is when I use help <name> it gives me the following:

>help Test

'Test' - Test Command

Expected usage: REPL.TestProject.vshost.exe Test

>

It assumes the currently running program must prefix all commands, which is not the case. I need either some way to edit the expected usage output, or put ManyConsole into a "REPL mode" where it excludes this.

On a side-note, if there were a "REPL mode" it might be able to replace my entire Main function. I could imagine an API like:

public static int Main(string[] args)
{
    var commands = GetCommands();
    
    return ConsoleCommandDispatcher.REPL(commands, ">", Console.Out);
}

Although if the second parameter were the command line prefix it might make sense to pass in a lambda expression or a function so that it can be variable (if you wanted to print the current working directory or the current database connection or something)

Then again, that might be too much effort and it may just be easier to add a boolean for tweaking the expected output 😄

What's the big idea

Hello,

I've known NDesk.Option to be perhaps the strongest command line argument parser available for awhile now. It's pretty good at organizing options and so forth.

However, what does ManyConsole do exactly that NDesk.Option does not already do? Can you elaborate on what it means for a class to inherit from ConsoleCommand? What does "differentiate" mean? I tend to think of options having specialized meanings depending on their context. Such as: service mode having a /A option, meaning service-A, or console mode also having an /A option, meaning console-A, whatever that may be.

Once you do, "ConsoleCommand" being the abstraction, that doesn't limit one to just console apps, am I correct? Seems like an obvious question: could be used for pure-console, services (i.e. with a console runner / service mode), and even graphical-UI?

Thank you...

[Feature Request] prompt for required option

An option which is required but must not be submitted as argument would be an interessting feature.
Sometimes this is useful, when you dont want the user to obtain a password or key via argument but only with an prompt after the command is started.

Unit Test

Hi,

Can you advise of how I could write some tests for my command line. I can't seem to access the command line values as they are part of the dispatch command.

I can test my app / class logic but cannot access the command line values that are parsed.

Thanks

Toby

Support attributes

I'd like support for attributes as alternative to initialisation in constructor:

[Command("upload")]
class UploadCommand : ConsoleCommand
{
    [RequiredOption("f|file=")]
    public string Filename { get; set; }
}

The consoleOut TextWriter is not provided to the commands

Hi!

I think it's cool that ManyConsole out of the box needs users to specify the outstream for the console, however it would be even cooler if that TextWriter was also available to commands.

For example when I do further validating of arguments in my command and then want to output an error message I'll have to rely on Console.WriteLine instead of using the passed in TextWriter.

Patch to improve visual studio debugging of ManyConsole programs

Hi,

Currently, any exception thrown by a ManyConsole program is caught then rethrown. This makes debugging with visual studio a bit painful because by default it will skip the actual error and stop on the second throw, after having forgotten all the context (e.g. local variables) at the original throw site. Here is a suggested patch to avoid this unnecessary catch and rethrow. Please let me know what you think.

Index: Source/ManyConsole/ConsoleCommandDispatcher.cs
===================================================================
--- Source/ManyConsole/ConsoleCommandDispatcher.cs  (revision 201)
+++ Source/ManyConsole/ConsoleCommandDispatcher.cs  (working copy)
@@ -80,23 +80,29 @@

                 return selectedCommand.Run(remainingArguments.ToArray());
             }
-            catch (Exception e)
+            catch (ConsoleHelpAsException e)
             {
-                if (!ConsoleHelpAsException.WriterErrorMessage(e, console))
-                    throw;
+                return DealWithException(e, console, skipExeInExpectedUsage, selectedCommand, commands);
+            }
+            catch (NDesk.Options.OptionException e)
+            {
+                return DealWithException(e, console, skipExeInExpectedUsage, selectedCommand, commands);
+            }
+        }

-                if (selectedCommand != null)
-                {
-                    if (e is ConsoleHelpAsException || e is NDesk.Options.OptionException)
-                        ConsoleHelp.ShowCommandHelp(selectedCommand, console, skipExeInExpectedUsage);
-                }
-                else
-                {
-                    ConsoleHelp.ShowSummaryOfCommands(commands, console);
-                }
+        private static int DealWithException(Exception e, TextWriter console, bool skipExeInExpectedUsage, ConsoleCommand selectedCommand, IEnumerable<ConsoleCommand> commands)
+        {
+            if (selectedCommand != null)
+            {
+                if (e is ConsoleHelpAsException || e is NDesk.Options.OptionException)
+                    ConsoleHelp.ShowCommandHelp(selectedCommand, console, skipExeInExpectedUsage);
+            }
+            else
+            {
+                ConsoleHelp.ShowSummaryOfCommands(commands, console);
+            }

-                return -1;
-            }
+            return -1;
         }

         private static ConsoleCommand GetMatchingCommand(IEnumerable<ConsoleCommand> command, string name)

Possibility to omit "Executing command" text

I cannot seem to find a way to omit the "Executing ..." text that is displayed before running any command. The only workaround I was able to think of is to provide TextWriter.Null to the DispatchCommand function, but this is not really useful, as we lose the help text and error messages as well.

Would you accept a pull request for this feature?

Allow for fields of nullable type in a ConsoleCommand class

Given the optional nature of some of the fields when using Optional args, it seems a bit counter-intuitive that ConsoleHelp.ShowParsedCommand() will throw an exception if one of the fields is a nullable type.

i.e. NullReferenceExcepetion at \Internal\ConsoleHelp.cs line 73

Unexpected (for me!) behavior with just one ConsoleCommand defined

Hi Frank,

first of all, thanks for providing ManyConsole. I've just begun using it and already like it very much.

I have however run into a problem if there's just one ConsoleCommand defined. This one gets executed even if that command wasn't on the command line, which doesn't seem right for me, or a least we should be able to choose if that's the way we want it. Maybe we can have a "IsDefault" property or something.
For now, I'm working around the issue by having another "dummy" command, but I don't think we should need to have something like that.
Or maybe there's already a way that I just don't see?

Thanks!
Jens

Ideas for possible some improvements

Hello. I am writing an utility and i decided to use your library. Right now i have 4 issues and maybe something can be improved, if you'd like:

  1. The idea of commands is very nice. However, right now i can't have multiple commands and run one command by default (when no args specified). Yes, this might be cryptic for users, but it's normal behavior for GUI apps (like Process Explorer and other Sysinternals tools): it runs normally by default, but if you pass args, it displays help in MessageBox or does what args tell it to do.
    Right now i'm using this hack:

    • if there are no args
    • or if there are args, and if first arg is not a command (checking by using copy of private static GetMatchingCommand because it's private!)
    • and arg[0] is not help
    • then insert name of default command to args[0]
    • then let your library do all the job like normal

    So i think you can add an optional argument to DispatchCommand or add metadata field to command to allow some command run as default one.

  2. As i mentioned, i'm writing a GUI app. I don't need int return code, and my main has void return type. If everything was ok, app does nothing, otherwise it displays a MessageBox with message and icon. However, can't return more than int from a command. Right now i just have public static MyResult Result {get; set;} field in Program class and set it from commands which is obviously too ugly. Maybe you can introduce generic ConsoleCommand<T> to allow users to return any type?

  3. I have strange behavior with setting default value for optional argument. If i don't specify the value, it is null every time. Maybe that's intended, but i expected from docs that Action gets called and i can check for null and set default value from there. For example:

    HasOption("c|config:", "Config file", x => ConfigFileName = x ?? "test");
    

    ConfigFileName is not set from this Action, i need to back it up with default value elsewhere.

  4. I can't get : or = in prototype to show default value instead of VALUE. Like in example above, i have in generated help: -c, --config[=VALUE] Config file. Am i missing something? I'd like it to be -c, --config[=test] Config file but when i specify "c|config:test", i gen an exception.

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.