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

ablility to rerun optparse.build more than once #22

Open
ewah opened this issue Jan 12, 2017 · 1 comment
Open

ablility to rerun optparse.build more than once #22

ewah opened this issue Jan 12, 2017 · 1 comment

Comments

@ewah
Copy link

ewah commented Jan 12, 2017

on occasion i need to reparse the options so we would need to without the defaults.

command -c config_file -i override

where it would read the config file first then reparse the args to override environment variable.

calling the code would look something like

source $( optparse.build )
if [ -n "$CONFIG_FILE" ]; then
  source $CONFIG_FILE_PATH
  # and reparsing
  source $( optparse.build "DEFAULT_OFF")
fi

and there needs to be stop gate like

# Set default variable values
if [[ "$*" == *DEFAULT_OFF* ]]; then
  echo -n ""
else
  $optparse_defaults
fi

# Process using getopts
OPTIND=1
while getopts "$optparse_arguments_string" option; do
        case \$option in
...

(note: OPTIND=1 )

@bitsofinfo
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants