Skip to content
This repository has been archived by the owner on Sep 7, 2018. It is now read-only.

posix-argv-parser fails when short option is combined with shorthand #391

Closed
samplx opened this issue Nov 23, 2013 · 1 comment
Closed
Assignees
Labels

Comments

@samplx
Copy link

samplx commented Nov 23, 2013

For example if there is a short option "-t" and a shorthand "-1", both -1t and -t1 will generate errors.

The following tests show the issue.

    "test shorthand first followed by short option": function (done) {
        this.a.createOption(["-t", "--terse"]);
        this.a.createOption(["--width"], { hasValue: true });
        this.a.addShorthand("-1", ["--width", "1"]);

        this.a.parse(["-1t"], done(function (errors, options) {
            refute(errors);
            assert(options["-t"].isSet);
            assert.equals(options["--width"].value, "1");
        }));
    },

    "test short option followed by shorthand": function (done) {
        this.a.createOption(["-t", "--terse"]);
        this.a.createOption(["--width"], { hasValue: true });
        this.a.addShorthand("-1", ["--width", "1"]);

        this.a.parse(["-t1"], done(function (errors, options) {
            refute(errors);
            assert(options["-t"].isSet);
            assert.equals(options["--width"].value, "1");
        }));
    },

    "test two shorthands followed by short option": function (done) {
        this.a.createOption(["-t", "--terse"]);
        this.a.createOption(["--width"], { hasValue: true });
        this.a.createOption(["--depth"], { hasValue: true });
        this.a.addShorthand("-1", ["--width", "1"]);
        this.a.addShorthand("-2", ["--depth", "2"]);

        this.a.parse(["-12t"], done(function (errors, options) {
            refute(errors);
            assert(options["-t"].isSet);
            assert.equals(options["--width"].value, "1");
            assert.equals(options["--depth"].value, "2");
        }));
    },
@dkl-ppi dkl-ppi added the Bug label Mar 7, 2014
@dkl-ppi dkl-ppi self-assigned this Mar 7, 2014
@dkl-ppi
Copy link
Member

dkl-ppi commented Mar 25, 2014

Fixed by 73a9f0df95 and released with version 1.0.1 of posix-argv-parser.

@dkl-ppi dkl-ppi closed this as completed Mar 25, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants