Open ddunbar opened 4 years ago
Something shorter would make for better defaults, especially with how long some property names can get. I like the idea of trying to select a value name that's appropriate for the type — we may even be able to hook into more information, like if you've indicated that the property is a file for autocomplete purposes (a la #1). What other default names would you expect beyond N
for integers and something like value
in the default case?
I'm not sure, very obvious ones to me are:
<N>
, for integral types<path>
, for path types<number>
maybe? doesn't actually come up that much in command line tools so maybe not important<str>
or <string>
for a string type, it does help to know the program thinks of it as a string, not sure I like the choice.One thing I wondered was if it would make sense to actually make the ExpressibleByArgument
be able to optionally provide this. So URL adopting could be <url>
, for example.
@vlm any thoughts on this?
Yes, I'd love it to be something that can be set in the ExpressibleByArgument
.
Suppose we had a ExpressibleByArgument.defaultValueName
to mirror ArgumentHelp.valueName
... how would we know whether to the defaultValueName
, valueName
, or the argument's property name as the valueName?
ArgumentHelp.valueName
is more local, so it would override anything from the protocol.
So ArgumentHelp.valueName
> ExpressibleByArgument.defaultValueName
> @Arg/Opt/Flag name
?
By default,
ArgumentParser
currently uses aArgumentHelp.valueName
derived from the option name. While this is a nice standard default, I think it often leads to overly verbose --help text, and customizing withArgumentHelp
makes declaration a little verbose (super kudos for having it possible in v0.0.1 though!).I think there is an argument to be made for having
ArgumentParser
use a default value name for well-known and common types, for example, usingN
for integral types.One upside of this is that it helps communicate the expected type.
I can understand if this is perceived to be too much magic, though...