Code Monkey home page Code Monkey logo

commandr's People

Contributors

jblachly avatar katyukha avatar kubo39 avatar robik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

commandr's Issues

feature enhancement: typed arg?

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.

"-" not allowed in option long-names

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:

if (!name.all!(c => isAlphaNum(c) || c == '_')()) {

Will simply adding another OR clause with "-" be sufficient or will somewhere else in the parsing logic blow up?

Options that accept space separated values

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

Options that could accept no values

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.

New release

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

version flag is not handled correctly

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.

opt.isDirectory: Error: template commandr.validators.validateEachWith cannot deduce function from argument types !()(Option, void), candidates are:

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?

Documentation site down

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.