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

Feature request: support for multi-value arguments #36

Open
stephenchu opened this issue May 10, 2016 · 3 comments
Open

Feature request: support for multi-value arguments #36

stephenchu opened this issue May 10, 2016 · 3 comments
Milestone

Comments

@stephenchu
Copy link

Will it be possible to support something like such in Bash getopts?

#! /bin/bash

while getopts ":t:" opt; do
  case $opt in
    t)
      TAGS+=($OPTARG)
      ;;
  esac
done
shift $((OPTIND-1))

for $tag in "${TAGS[@]}"; do
  echo "Tag: $tag"
done

Output:

$ foo.sh -t one -t two
Tag: one                                                                                            
Tag: two                                                                                            
@RenatGilmanov
Copy link

RenatGilmanov commented May 12, 2016

Do you mean just to incorporate tags or multi-value parameters into the template? Like the following

while getopts ":vht:" optname
  do
    case "$optname" in
      "v")
        echo "Version $VERSION"
        exit 0;
        ;;
      "h")
        echo $USAGE
        exit 0;
        ;;
      "t")
        TAGS+=($OPTARG)

@stephenchu
Copy link
Author

I meant having multi-value parameters. "tags" is just an example of mine as most things that are taggable these days have multiple tags.

The existing boolean/integer/float/string data types may not be sufficient to represent TAGS in the example. It might make sense to have DEFINE_array but I can imagine it being pretty difficult to implement.

@RenatGilmanov
Copy link

Ok, I see. You are right saying multi-value parameters are pretty useful. Will try to reuse/invent something. Thank you for providing valuable comments and sharing your ideas.

@kward kward added this to the 1.2.4 milestone Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants