From c332e9b32bc673d481259aabdf27b2b9875077f2 Mon Sep 17 00:00:00 2001 From: primardj Date: Mon, 25 Mar 2024 00:28:49 +0000 Subject: [PATCH] add the shebang and parametters -v -V -h --- network_control.sh | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/network_control.sh b/network_control.sh index 09080a7..db502a4 100755 --- a/network_control.sh +++ b/network_control.sh @@ -1,7 +1,7 @@ - +#!/bin/sh # Script which control the network. Make the bridge, veth, dummy, brx alone without any help. -version="0.0.1" +version="0.0.2" usage="USAGE $(basename $0) [PARAMETTER] [COMMAND NAME] @@ -16,7 +16,8 @@ DESCRIPTION PARAMETTER -h, --help Print this help message and quit - -v, --version Print the installed version of $(basename $0) and quit + -V, --version Print the installed version of $(basename $0) and quit + -v, --verbose Print more output for all actions. NAME Is the name of the vm to open @@ -28,6 +29,29 @@ COMMAND " -echo "$usage" +print_usage() { + echo "${usage}" +} + +print_version() { + echo "$(basename $0) v.${version}" +} + +# first, test if there is help, version, or verbose args. +for i in "$@"; do + case "$i" in + "-h" | "--help") + print_usage + exit 0 + ;; + "-V" | "--version") + print_version + exit 0 + ;; + "-v" | "--verbose") + set_verbose + ;; + esac +done