robik / commandr Goto Github PK
View Code? Open in Web Editor NEWA modern, powerful commmand line argument parser ๐จ
License: MIT License
A modern, powerful commmand line argument parser ๐จ
License: MIT License
I was just playing around with your library (cool work so far) and noticed that the version flag is not handled correctly. Code to reproduce:
import std.stdio;
import commandr;
void main(string[] args) {
auto a = new Program("example", "3.14")
.add(new Argument("foo", "a mandatory argument"))
.parse(args);
writeln(a.arg("foo"));
}
Expected output:
$ ./example --version
3.14
Actual output:
$ ./example --version
Error: missing required argument foo
example [-h] [--version] foo
I think already I have a solution for this and will open a PR after I tested it.
Hi,
Right now the arg's type is either string, or string[], and user need to convert manually to other types, e.g.
int depth = args.arg("depth").to!int;
is it possible to allow user specify the arg type directly, e.g.
.add(new IntArgument("depth", "dir depth"))
and access it directly later as:
int depth = args.arg("depth"); // directly get int value
Thanks.
Using "-" as word separator in long option names has a long history, and options of many compilers contain long option names (eg --disable-loop-unrolling
).
However this seems not to be allowed:
commandr.program.InvalidProgramException@/home/james/.dub/packages/commandr-0.2.0/commandr/source/commandr/program.d(49): invalid name 'min-length' passed
due to this:
commandr/source/commandr/program.d
Line 350 in ae3b16b
Will simply adding another OR clause with "-" be sufficient or will somewhere else in the parsing logic blow up?
No activity on PR, and issue update, since Jan.
Sign, it works so nicely.
Hi,
First of all, thanks for great library. It is really awesome)
And, it would be nice, if you release new version that supports dashes in option names. I see that these changes are already on master, but there is no release with this functionality yet.
Thanks
I tried the example code:
.validateEachWith(opt => opt.isDirectory), "must be a valid directory");
but it errors out:
Error: template commandr.validators.validateEachWith cannot deduce function from argument types !()(Option, void), candidates are:
.dub/packages/commandr-0.1.1/commandr/source/commandr/validators.d(458,10): validateEachWith(T : IEntry)(T entry, void delegate(IEntry, string) validator)
.dub/packages/commandr-0.1.1/commandr/source/commandr/validators.d(488,10): validateEachWith(T : IEntry)(T entry, bool delegate(string) validator, string errorMessage)
I changed to isDir
or isFile
:
https://dlang.org/library/std/file/is_dir.html
https://dlang.org/library/std/file/is_file.html
still doesn't work. Should the function
be added in addition to delegate
?
And can you add an example.d?
I want to use this to help me begin writing CLI applications in D but it seems as if the site for documentations just does not exist anymore?
Is there anywhere else I can find it?
Thank you
One of my utilities does the following:
kpd -p 2
[ play song number 2 ]
kpd -p
[pause or resume playing]
At the moment commandr allows only Options (useful in the first case) and Flags (useful for second case).
Can a mixed Option/Flag be added? Or even better a Class that accepts all kind of inputs but requires a validator.
I was wondering if there is a possibility of having a Option that accept multiple space separated values or alternatively a function to specify how many parameters are needed by Option .
Example:
test --delete file1 file2 file3
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.