Skip to content

Tags: modpm/cmd

Tags

v0.3.1

Toggle v0.3.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Refined parser error messages for flags given `=` values (#14)

This PR improves the clarity of argument parser messages when a boolean
flag is incorrectly provided with a value using `=`.

Previously, cases like `-f=val` or `--flag=value` would produce
misleading messages such as ‘unknown option '-f'’ even if the flag
exists. Now, the parser reports more precise messages:

- `unexpected '=' for option '-f'`
- `unexpected '=' for option '--flag'`
- `unexpected '=' in combined short options '-ff'`

v0.3.0

Toggle v0.3.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Count number of occurrences for flags (#11)

`ParsedArgs` now stores the number of times boolean options (flags) were
encountered in the command line.

Example: `-vvvv` or `-v -v -v -v` will return `4` for `flag("-v")` as an
unsigned integer.

To check whether a flag is present (i.e. > 0 occurrences), use
`hasFlag("-v")`.

## Breaking Change

The old `bool flag(string | Flag)` method has been renamed to `bool
hasFlag(string | Flag)`.

The new method `uint flag(string | Flag)` is different and works as
described in this PR and in the documentation.

v0.2.1

Toggle v0.2.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix bug introduced by feature in #10 (#12)

The feature checks for flags grouping like `-abc` but falsely interprets
sequences like `-a=value` as a group of flags.

v0.2.0

Toggle v0.2.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Added support for grouping boolean options by short name (#10)

Flags (boolean options) like `-a -b -c` can be grouped like `-abc` (in
any order). Only works for flags/booleans and only for short options.

Example:

```d
new Program("cmd")
    .option("-f, --foo", "foo")
    .option("-b, --bar", "boo")
    .option("-B, --baz", "foo")
    // …
```

The flags can be set to true like so:

```sh
cmd -fbB
# equivalent to:
cmd -f -b -B
```

When reading the parsed flags, they are still read separately:

```
auto foo = args.flag("-f");
auto bar = args.flag("-b");
auto baz = args.flag("-B");
```

v0.1.3

Toggle v0.1.3's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix flag explicit selection with `-` and `--` (#9)

Store flags with their full name (including `-` or `--`) to enable
explicit selection by short (`-`) and long (`--`) name, just like
options (named parameters).

v0.1.2

Toggle v0.1.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Check `arg` is not empty before accessing `front()` (#8)

Fixes bug with 0-length args, e.g.

```
./cli ""
```

v0.1.1

Toggle v0.1.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Improved README and examples (#6)

v0.1.0

Toggle v0.1.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Initialise project (#1)

TODO:

- [x] Finish the `printHelp()` method
- [x] Add CI
- [x] Examples in README
- [x] Documentation (outside of source)

v0.1.0-dev.2

Toggle v0.1.0-dev.2's commit message

Verified

This commit was signed with the committer’s verified signature.
zefir-git Zefir
fix typo

v0.1.0-dev.1

Toggle v0.1.0-dev.1's commit message

Verified

This commit was signed with the committer’s verified signature.
zefir-git Zefir
added CI