Skip to Content
Command Line Tools

20. Args

2019-02-07Original-language archivelegacy assets may be incomplete

Shell

# getopts
# : after letter indicates it requires arguments
while getopts ":a:" opt; do
  case $opt in
    a)
      echo "-a was triggered, Parameter: $OPTARG" >&2
      ;;
    \?)
      echo "Invalid option: -$OPTARG" >&2
      exit 1
      ;;
    :)
      echo "Option -$OPTARG requires an argument." >&2
      exit 1
      ;;
  esac
done
 
# getopt

Python

argparse