Set `no_short` by default
tailhook opened this issue · comments
I think no_short
should be the default. Not only because short options are a scarce resource, but also for forwards compatibility:
- It's hard to keep track of which short options are used and what aliases are left. I.e. when you want to add a very important short option in future.
- It's too easy to move fields in a struct when refactoring, and forget that their shortcuts are swapped now.
- Also, many options don't even need a short option at all. It's common practice to have only long form for majority of options.
I know it's not backward compatible. But I always feel on minefield when adding an option with autogenerated shortcut. What do you think?
I don't want to change the default behavior, but you make some good points. So, how about this for a compromise:
#[derive(Default, Options)]
#[options(no_short)] // Sets no_short by default on all fields
struct Opts {
foo: bool, // No short flag
#[options(short = "b")] // Explicit short flag provided; overrides default
bar: bool,
}
Yes, this would work for me. (I.e. less issues on code review when adding a parameter on existing structure).
I'm curious anyway, are there any reasons besides backward compatibility?
I've pushed the implementation for type-level attributes.
My hesitation about changing the default behavior here is less about backward compatibility and more about simplicity, user expectation, and avoiding making typical configuration too verbose.
Okay. Type-level attribute works. Thank you!