Commit Graph

7 Commits

Author SHA1 Message Date
Isaac Freund
e18d0d5e1c
flags: automatically prepend '-'
This makes the usage a bit cleaner as the results of the parsing may be
accessed with e.g. ret.flags.version instead of ret.flags.@"-version".
2022-12-28 22:11:14 +01:00
Isaac Freund
16cbe5f469
flags: rewrite to allow [:0]const u8 arguments
This also cleans up the code by using @Type(), eliminating the need
for the argFlag() and boolFlag() functions.

Allowing [:0]const u8 arguments makes this parser useful for
river-control commands as well.
2022-12-28 20:21:23 +01:00
Isaac Freund
79d7775a3d
code: relicense to GPL-3.0-only
I don't need anyone's permission to make this change since
GPL-3.0-or-later is one-way compatible with GPL-3.0-only.
2022-01-31 19:33:22 +01:00
Isaac Freund
c3370afa3d
common/flags: make argFlag() return a slice
We always pass the result of this to mem.span() currently, no need for
the code duplication.
2021-12-15 17:09:45 +01:00
Isaac Freund
23088b800c
common: standardize on -help option
Also:

- Check for -help option *before* unknown options
- Use common flags parsing code for riverctl
- Add usage text to riverctl
2021-07-24 19:31:04 +02:00
Isaac Freund
a5a505ecba
common: remove support for positional arguments
This is currently unused and I don't like the approach anymore
regardless. If/when we need positional arguments (probably when
implementing the upcoming river-control protocol in rivertile)
they should be handled separately from flags.

This commit also improves the CLI error reporting to always print the
usage string if invalid arguments were passed.
2021-07-24 18:29:48 +02:00
Isaac Freund
f6fa3425de
river: use common CLI arg parsing code
This makes river's main() function quite a bit cleaner.
2021-07-24 16:44:11 +02:00