Replies: 3 comments 2 replies
-
Thanks!
Positional is just a positional argument and I didn't want write that all out, but we could. It could also be The "free" that I have here is complicated, because it's essentially a new concept. It's free in the sense of being able to appear everywhere, as long as it fits the predicate. It could also be "custom" or "predicate" or "guarded"? I have an issue for conflicting arguments: https://github.com/tertsdiepraam/uutils-args/issues/11 The priority is fairly low because you could implement it manually and it's not used much in the coreutils. A manual (but pretty low-effort and bad) implementation would look something like this: enum Arg {
#[option("--foo")
Foo,
#[option("--bar")
Bar,
}
struct Settings {
foobar: Foobar,
foobar_set: usize,
}
impl Options<Arg> Settings {
fn apply(&mut self, arg: Arg) {
match arg {
Arg::Foo => {
self.foobar = Foobar::Foo;
self.foobar_set += 1;
}
Arg::Bar => {
self.foobar = Foobar::Bar;
self.foobar_set += 1;
}
}
}
}
// then check `foobar_set` afterwards This could be made easier if |
Beta Was this translation helpful? Give feedback.
-
https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/basedefs/V1_chap12.html - I took some terminology for bpaf from here |
Beta Was this translation helpful? Give feedback.
-
I think I've resolved everything in here now :) |
Beta Was this translation helpful? Give feedback.
-
As promised some feedback. It's from a user's PoV, from looking at the tests.
Overall, impressive work!
Initial
seems to me to be the wrong noun, it means "the first letter of a word or name" according to the dictionary.Similarly,
positional
andfree
are not nouns and so don't fit tooption
. Plus I don't understand why it's namedfree
as it specifies the parser function for the corresponding option.With the defaults, why do you introduce
#[initial(..)]
instead of usingstd::default::Default
?I assume things like "option x conflicts with option y" are outside the scope of this library?
Beta Was this translation helpful? Give feedback.
All reactions