Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add command options for help and version. #36

@virgilwashere

Description

@virgilwashere

Add -h and -V options

Basic getopts version:

  #-----------------------------------------------------------------------
  #  Handle command line arguments
  #-----------------------------------------------------------------------
  while getopts ":hV" opt
  do
    # shellcheck disable=SC2214
    case "${opt}" in

      h|help      ) _usage;    exit 0 ;;
      V|version   ) _version;  exit 0 ;;

      \?  ) printf '\nInvalid option: %s\n\n' "${OPTARG}"
            _usage;    exit 2 ;;

    esac    # --- end of case ---
  done
  shift $(( OPTIND-1 ))

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions