question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for commands

See original GitHub issue

Issue by fleed Friday Mar 31, 2017 at 04:24 GMT _Originally opened as https://github.com/gsscoder/commandline/issues/434_


Is there any existing way to define commands, intended as classes to execute specific options? IF not, any plan to add support? I would expect something like this, removing lot of the ceremony required to configure the option and run the related logic:

Example:

class CommitCommand : Command<CommitOptions>
{
    public int Execute(CommitOptions options)
    {
        // execute
        return 0;
    }

    // alternative
    public int Execute()
    {
        // access options as property in AsyncCommand base
        var file = this.Options.File;

        // execute
        return 0;
    }
}

class UploadCommand : AsyncCommand<UploadOptions>
{
    public async Task<int> ExecuteAsync(CommitOptions options)
    {
        // execute
        return 0;
    }

    // alternative
    public async Task<int> ExecuteAsync()
    {
        // access options as property in AsyncCommand base
        var file = this.Options.File;

        // execute
        return 0;
    }
}

// Program.cs
var parser = new CommandParser();
var parserResult = parser.Parse(args);
var result = parserResult.ExecuteCommand();

In general I’d like the possibility to discover options and commands through reflection, something similar to ManyConsole.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
georgiosdcommented, Nov 6, 2017

@ericnewton76 sure, but no support for async 😦 With async main support in C# 7.1, that’s a very important feature.

0reactions
Fumblesneezecommented, Dec 19, 2017

this reply was directed to @fleed .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show Supports Commands badge on bots in which 75% ...
Show `Supports Commands` badge on bots in which 75%+ guilds have a guild command.
Read more >
Command support definition and meaning
Command support definition: If someone in authority commands you to do something, they tell you that you must do it.... | Meaning, pronunciation ......
Read more >
Support CLI Commands
There are no functions that you would perform with these commands regularly. support clean audit_results: A way to manually purge audit results, this...
Read more >
Help Command: Examples, Options, Switches and More
Curious about how your computer commands work? The help command can help with that. Here's how to use the help command in Command...
Read more >
New badge for bots that support slash commands
Though... the prompt for command arguments really helps on complex bot commands tbh (like when using the bots myself). A shame it couldn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found