Comments (6)
There are a lot of details with the merging API you're proposing that seem tricky in practice. What happens if the results are from different parsers? What if they both have positional parameters? What if they select different commands? What if the parser relies on callbacks rather than after-the-fact parsing? These aren't necessarily insurmountable, but the fact that the answer is non-obvious makes me wonder if merging ArgResult
s after the fact is the best way to represent this idea.
In test
, we support this by having a separate Configuration
class that can be populated using args or by loading from a file. This gives us more flexibility in terms of the configuration file, where CLI flags aren't necessarily the best UI for setting options (test
uses YAML instead) and where not all options configurable via CLI make sense. It also gives us a well-typed way of accessing the configuration, and finer-grained control over exactly how options are merged between different sources.
It is hard for a user to merge each
List<String>
before parsing them
Can you go into more detail about why this is difficult?
from args.
Merging the List<String>
s manually before parsing them with ArgParser is hard because you have to parse them anyways. You might have flag --force
with a short value -f
, and then you might have --force
on the cmdline and -f
from another source, and you're just re-writing the package:args parser.
I'd be happy with the following constraints on such a merge (which could be relaxed later if demand arises):
- Must come from same ArgParser
- Must not include positional parameters, or maybe just that
other
's values overwritethis
's values. - Maybe different commands don't matter?
- Callbacks might be tricky... On the face of it, they're just not run again? Probably not a good idea to use callbacks if you're going to merge?
from args.
Merging the
List<String>
s manually before parsing them with ArgParser is hard because you have to parse them anyways. You might have flag--force
with a short value-f
, and then you might have--force
on the cmdline and-f
from another source, and you're just re-writing the package:args parser.
Can't you just concatenate the lists? args
can handle multiple instances of the same argument; it'll just overwrite the value if necessary.
from args.
@srawlins has this come up again since you filed the request?
I do think that concatenating the args should work in the limited cases we are likely to be able to support here, and that for more complicated cases you'd need to handle conflicts and everything with application specific logic.
from args.
I don't think so. I'm not certain which project triggered this request, 4 years ago :/
from args.
Closing for now until we find a current use case.
from args.
Related Issues (20)
- Overhaul usage errors to not use exceptions
- Examples for CommandRunner aren't correct on pub page HOT 3
- Statically typed argument parser (possibly with code generator)? HOT 3
- Add a CommandRunner example HOT 2
- Why is `CommandRunner._usageWithoutDescription` private?
- Promote Command.argResults to be non-nullable HOT 1
- Make allowed options case insensitive
- How to add default command?
- Provide the function to print strings in nice columns
- Standards used in docopt. HOT 2
- [Feature request] Show command alias in usage HOT 3
- Command CommandRunner Platform.executableArguments HOT 3
- use of 'mandatory' options breaks handling of the help flag
- Feature request: parse complete command string to List<String> args HOT 3
- Analogue of '::' GNU getopt extension? HOT 1
- `--` needs to be escaped on Windows HOT 2
- Usage should be able to show additional info for trailing options (rest)
- Setting the mandatory parameter of the addOption function to true has no effect. HOT 1
- `takesArguments` should change the usage text
- Incorrect message in `dart_site --help` HOT 1
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 args.