From 3b17b736d3675674da39acf78540d1cb6bf5970d Mon Sep 17 00:00:00 2001 From: TuDatTr Date: Sat, 23 May 2020 18:25:34 +0200 Subject: [PATCH] Added -h/--help and fixed a typo --- README.md | 2 +- install.sh | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c1bcf89..55c096d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # March -A small script to automate my archlinux configuration \ No newline at end of file +A small script to automate my archlinux configuration. diff --git a/install.sh b/install.sh index f8a307c..f78d3b8 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -o errexit -o pipefail -o noclobber -o nounset ! getopt --test > /dev/null @@ -8,8 +7,8 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then exit 1 fi -OPTIONS=dtlhus -LONGOPTS=device,timezone,locale,hostname,username,sudogrp +OPTIONS=dtlhush +LONGOPTS=device,timezone,locale,hostname,username,sudogrp,help ! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") if [[ ${PIPESTATUS[0]} -ne 0 ]]; then @@ -52,9 +51,25 @@ while true; do sudogrp="$2" shift 2 ;; + -h|--help) + description=$(< tail -n +3 $CWD/README.md) + echo " +Usage: ./install.sh -d [DEVICE] -t [/usr/share/zoneinfo/REGION/CITY] -l [LOCALE] -h [HOSTNAME] -u [USER] -s [SUDO] + +Mandatory arguments: +-d | --device Device that shoud be partitioned e.g. "/dev/sda" +-t | --timezone Your timezone according to /usr/share/zoneinfo/ e.g. "/usr/share/zoneinfo/EUROPE/Berlin" +-l | --locale Your locale according to /etc/locale.gen e.g. "en_US.UTF-8 UTF-8" +-h | --hostname Name for your machine e.g. "ArchLinux" +-u | --username Your username e.g. "foo" +-s | --sudogrp Name of the sudogrp +-h | --help This ehre. + " + exit 0 + ;; *) echo "Programming error" - exit3 + exit 3 ;; esac done