mailund / cli Goto Github PK
View Code? Open in Web Editor NEWCommand line parsing for go
License: GNU General Public License v3.0
Command line parsing for go
License: GNU General Public License v3.0
I'm not sure where in the source I can add documentation for the tags, but it has to go somewhere.
The README doesn't describe that a struct can have a callback field.
Ideally, we should get the options in a choice from the keys of a map, but then I need to handle all kinds of maps or use reflection, which gives the user an ugly interface. I'll wait for generics before I do that. A generic map[string]T will make it easy, and generics shouldn't be far away now...
This is doable in various ways, but I don't know if I can do it without making too strong a coupling between commands, that I might not want to have.
Go's flags start with a single dash but almost everyone else use double dashes for flags with more than one character in the name. Check if there is a replacement package I can use instead of flag.
Flag help shows "--flag value", but the types can change "value", and since I autogenerate them, I should do that. Same for the files. Choices already do this.
When a parameter must be one of a set of options, the user shouldn't have to use a string parameter and then check the result him/herself. It is simple to create a set of options, so that should be part of params.ParamSet. I can't insert the same in flag module, but with a callback function it should be easy to add the functionality.
Show how the commands are used in a complete program, and show the usage information they print.
If an argument is a reader or writer, the parser can open the files automatically. For flags, the default can easily be set to stdin/out/err
I don't need the non-Var functions with the new commands, so I can cut the interface in half.
With the callback interface, I really only need two functions, one for installing a positional argument and one for a variadic. They should then call a callback.
The different types of variables leads to some duplicated code, but maybe I can generate that code automatically.
Flags have a Value interface that can work as a callback interface. If I can check if the field implements that, then I can do the same. It might be a simpler interface for extending the module.
The subcommans always gobble up the rest of a command-line, so we can't have variadic parameters as well...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.