Comments (7)
For question 1, yes, but not yet. The next update I publish will add a [HelpHook] attribute to your help property (more on that below). I added this in part because of your question (thanks). I will probably publish within a couple of weeks. I'll leave this issue open until then.
For question 2, boolean properties already work that way.
If the user doesn't specify '-help' at all then the Help Property will have a value of false.
If the user types '-help' then it will have a value of true.
If the user types '-help true' then it will have a value of true.
If the user types '-help false' then it will have a value of false.
If you use the new [HelpHook] I talk about above then whenever the user indicates 'true' for the help property then it will not only have a value of true, but it will stop processing so the system does not try to invoke an action. It will finally print the help automatically for you (which you can turn off if you want to print it yourself).
from powerargs.
Looks good!
Is there a way though, that you could change the context if an action is specified?
e.g.
superencoder -help
Writes the full usage text - context = SuperEncoderArgs
superencoder encode -help
Only writes the usage text of EncoderArgs, not SuperEncoderArgs
superencoder clip -help
Similarly, only writes the usage text of ClipArgs.
from powerargs.
That's a good idea for a feature. I've thought of it before, but nobody asked for it until now. Let's leave this issue open until I can get to it.
from powerargs.
Looking at how git behaves, I wonder if the behaviour could be:
superencoder -help
Shows the list of Actions and their ArgDescriptions only ([Optionally or otherwise] does not recursively drill down into their properties)
superencoder encode -help
Shows the usage text of EncodeArgs, as mentioned before.
What do you think?
from powerargs.
Sorry for the delay. I think that sounds good. Another person opened a similar issue recently. Hopefully I can get to this soon.
from powerargs.
This is now working. Below is an example that shows how to manually use the usage API to set the specified action in the context of an exception. The default exception behavior now works like you asked in your last message. That is, if you're using the Args.InvokeAction() method, and you are using the [ArgExceptionBehavior(ArgExceptionPolicy.StandardExceptionHandling)] attribute on your main class then by default only the action specific usage will be printed when the error is in the context of an action. I'll leave the issue open until the next NuGet publish,
public void TestActionSpecificUsage()
{
try
{
Args.InvokeAction<ArgsForActionSpecificUsage>("Foo");
}
catch (ArgException ex)
{
var usage = ArgUsage.GetStyledUsage<ArgsForActionSpecificUsage>("test", new ArgUsageOptions()
{
SpecifiedActionOverride = ex.Context.SpecifiedAction
});
Assert.IsTrue(usage.Contains("Foo"));
Assert.IsFalse(usage.Contains("Bar"));
}
}
from powerargs.
Fixed
from powerargs.
Related Issues (20)
- Add support for a warning on usage of obsolete enum value HOT 1
- Implementation of ContextAssistSearch doesn't get initialized HOT 1
- Slash (/) with positional arguments running on Linux & MacOS HOT 2
- How to specify command line parameters with double dashes (eg. --help) HOT 1
- Boolean args as 'flags'? HOT 1
- String args with 'null' as default throw unhandled exception HOT 1
- New Release Pending? HOT 1
- validation message missing for ArgCantBeCombinedWith HOT 1
- Prompting for input despite PromptIfMissing=false on Required arg HOT 3
- Allow zero-length list of argument values to be terminated by next option
- How to parse into an array? HOT 2
- Issue with scrolling in console HOT 2
- Issue running on Linux HOT 3
- Scrolling and background issues on 4.0.0. Works on 3.6.0 HOT 2
- Some links broken in README.md HOT 1
- Validator only checks first item in List arguments HOT 1
- Release 4.0.2 is not strongnamed (4.0.0 is, as well as 3.6.x) HOT 1
- Change executable name in 'help'?
- bool reviver not working
- Use param label as value
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 powerargs.