optparse icon indicating copy to clipboard operation
optparse copied to clipboard

ablility to rerun optparse.build more than once

Open ewah opened this issue 7 years ago • 1 comments

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 )

ewah avatar Jan 12 '17 23:01 ewah

+1

bitsofinfo avatar Mar 13 '17 14:03 bitsofinfo