Skip to content

ablility to rerun optparse.build more than once #22

@ewah

Description

@ewah

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 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions