Comments (7)
It works if I add this constructor:
public MyVerbs()
{
Foo = new FooOptions();
}
However, I was hoping to be able to use the convention of "only one options-property will be non-null, and its corresponding run method should be invoked".
Do you have any suggestions how to determine which "verb logic" should be run? Manually check the first string in args
?
from commandline.
I was working on the subject on this moments... (committed less than one minute!)
I've made a little fix, so check if it solved.
For now, in the principle of developer freedom, I've used a property-base verb design. This allow more freed, as said, about instance management penalizing a little elegance :(.
So check the last wiki (updated this moment). For now you've to check manually:
if (CommandLineParser.Default.WasVerbOptionInvoked("foo")) {
// app foo --options invoked
} else if(CommandLineParser.Default.WasVerbOptionInvoked("bar")) {
// app bar --options invoked
}
I remember your suggestion of a method-based design and I'm going to add this to the default way. After all, this library always used reflection, "weak contracts" and more paths to get thing done.
// this will remain valid
[VerbOption("commit", HelpText = "Record changes to the repository.")]
public CommitSubOptions CommitVerb { get; set; }
// along with
[VerbOption("commit", HelpText = "Record changes to the repository.")]
public CommitVerb(CommitSubOptions subOptions)
{
// do stuff here
}
Backing to your sample, give me some time. I'll check it and reply here. Thanks for reporting!
from commandline.
Also check pull request #46, it uses the Activator
to create an instance if (and only if) the developer hasn't assigned a non-null value to the options property.
WasVerbOptionInvoked
looks good enough to me, I'll use that to wire verbs to methods, thanks!
from commandline.
Thank to you!
The problem is clear...
When you request help, the instance is still not created. Simply a bug that must be fixed!
But it is simple, I think... I'll back soon.
from commandline.
Any feedback on the pull request? :) Was I way off?
from commandline.
Thanks. After the last comment I switched to fixing. I see now that the pull solve this issue too!
I've fixed before the call occur. It is essentially the same; the problem is that this "case" escaped also from unit test... (I've to start using PEX also for this project!).
Please give a try and if it works, we can close the issue.
from commandline.
It works, closing.
from commandline.
Related Issues (20)
- Support for default verb? HOT 7
- Is version 2 still beta? HOT 3
- Cannot use 2 verbs at the same time HOT 5
- Mutual exclusive option is not enforced (even when settings.MutuallyExclusive == true) HOT 3
- Has the approach to verbs in v2 changed? HOT 6
- THIS REPO GOING DEFUNCT, please submit issues/pull requests to https://github.com/commandlineparser/commandline HOT 2
- Argument value with dash not accepted when using single-dash key HOT 1
- Good, except parsing doesn't work HOT 1
- Parser state HOT 1
- Using --help HOT 1
- Inverse order of FlatternHierarchy HOT 1
- Enum Parsing Is Failing HOT 2
- Migrating from 2.3.0 to 2.4.3 HOT 3
- Please support older .NET framework versions
- Unable to parse TimeSpan given from FormatCommandLine HOT 2
- Order of options where there are list options and values HOT 1
- Group where none or all options must be provided HOT 1
- Fast HOT 1
- (Tool's);
- Tv
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commandline.