#!/usr/bin/env bash # CONSTANTS CONTAINER_PREFIX= TYPE=container # FUNCTIONS function usage { echo "$(basename "$0") [CONTAINER_PREFIX] < --vm >" } function parse_options { while [[ $# -gt 0 ]]; do case "$1" in --help | -h) usage && exit 0 ;; --vm) TYPE='VIRTUAL-MACHINE' ;; *) if [[ -z $CONTAINER_PREFIX ]]; then CONTAINER_PREFIX=$1 else echo >&2 "Unknown option: $1" && usage && exit 2 fi ;; esac shift 1 # Move to the next argument done } function ls { incus list -c ns4 -f compact,noheader "$CONTAINER_PREFIX" type=$TYPE } # MAIN parse_options "$@" ls