slap
slap copied to clipboard
Find a way to not have slap-variables conflict with user-variables
Hi, there are enough examples to get started with Slap, but I'm left with unanswered questions about how the variables are named.
Take the first example, with an argument named username
:
why is the associated variable named _username_vals
rather than username
?
Are there any benefits for the extra _...._vals
?
Are these benefits worth the loss in readability ?
Does the leading underscore mean that _username_vals
shouldn't be used directly ? If so, why ?
Cheers, and thanks for your work !
The leading _ is configurable.
cargo r -q -- parse bash prefix_ -- fast <complete.yml
gives you:
prefix_success='true'
prefix_usage='USAGE:
yml_app [FLAGS] [OPTIONS] [--] [pos]'
prefix_pos_occurs='1'
prefix_pos_indices=('1')
prefix_pos_vals=('fast')
cargo r -q -- parse bash -- fast <complete.yml
gives you:
success='true'
usage='USAGE:
yml_app [FLAGS] [OPTIONS] [--] [pos]'
pos_occurs='1'
pos_indices=('1')
pos_vals=('fast')
I normally use _ to separate slap variables and non-slap variables.
In fact the extra _vals
is not necessary, we could even remove it.
Ok actually I've thought about it a bit more and if we remove _vals
, then if you have an option called success
for example, it will conflict with slap's success
variable.
We should find a way to not have user-variables conflict with slap-variables