matejak / argbash

Bash argument parsing code generator
Other
1.39k stars 63 forks source link

Issue to retrieve values when defining camelCase arguments #154

Closed cazzoo closed 1 year ago

cazzoo commented 3 years ago

Hello,

I'm using argBash to wrap my CLI and it's working quite well except when you set arguments as camelCase. I couldn't find the information that explicitly tells not to use camelCase so I was expecting it to work without any issue. Question is: Will you be in position to support camelCase arguments? Otherwise, could you please update argbash documentation to highlight this limitation.

Examples of camel case arguments: ARG_OPTIONAL_SINGLE([myVar], [v], [My Variable], [default value])

When trying to get value using : ${_arg_myVar}, ${_arg_my_var} or ${_arg_my_Var}, nothing happens.

Kindly regards,

gdevenyi commented 3 years ago

Can you please share both the example argbash template code you're using and the resulting output.

cazzoo commented 3 years ago

Hi, here is the argBash template for this script:

#
# This is a rather minimal example Argbash potential
# Example taken from http://argbash.readthedocs.io/en/stable/example.html
#
# ARG_OPTIONAL_SINGLE([myVar], [v], [My Variable], [default value])
# ARG_HELP([The general script's help msg])
# ARGBASH_GO

# [ <-- needed because of Argbash

echo "Value of --option: ${_arg_myVar}"

# ] <-- needed because of Argbash
gdevenyi commented 3 years ago

Can please edit your comment to be properly formatted as code, https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks

cazzoo commented 3 years ago

Oh, I'm really sorry @gdevenyi, I didn't checked code format and trusted the single backtick... My previous comment has just been updated to parse code the proper way.

matejak commented 1 year ago

The answer is very simple, the variable is named _arg_myvar, as you can read from the generated code. IOW, the name is converted to lowercase, while the rest s.a. help messages is preserved.

matejak commented 1 year ago

See also: https://argbash.readthedocs.io/en/latest/guide.html#using-parsing-results