Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find a way to not have slap-variables conflict with user-variables #7

Open
ngirard opened this issue Nov 4, 2020 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@ngirard
Copy link

ngirard commented Nov 4, 2020

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 !

@guardam
Copy link
Owner

guardam commented Nov 6, 2020

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.

@guardam guardam closed this as completed Nov 6, 2020
@guardam
Copy link
Owner

guardam commented Nov 6, 2020

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.

@guardam guardam reopened this Nov 6, 2020
@guardam
Copy link
Owner

guardam commented Nov 6, 2020

We should find a way to not have user-variables conflict with slap-variables

@guardam guardam changed the title Document the variable naming scheme & its rationale Find a way to not have slap-variables conflict with user-variables Nov 8, 2020
@guardam guardam added the enhancement New feature or request label Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants