summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-06-05 14:36:56 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-06-05 14:36:56 +0200
commit0c909a46ca5be32604157e57bc2ba61a8fcfe335 (patch)
tree16af453c78e61e8c31728f5cd897da354b823b3d
parent30ebeccee311766c2be457dcaa707b5055e7e6b4 (diff)
parentca9e8520f95c64e4fce8a221f555b9b23731bd2b (diff)
Merge pull request #14 from matthiasbeyer/add-help_utils
Add help utils
-rwxr-xr-xnix-script2
-rwxr-xr-xnix-script-diff-generations.sh4
-rwxr-xr-xnix-script-ls-profiles.sh5
-rw-r--r--nix-utils.sh17
4 files changed, 23 insertions, 5 deletions
diff --git a/nix-script b/nix-script
index 1c74471..547e41f 100755
--- a/nix-script
+++ b/nix-script
@@ -92,7 +92,7 @@ then
stdout "Listing commands"
for cmd in $(all_commands)
do
- echo "$cmd" | sed 's,^\.\/nix-script-,,' | sed 's,\.sh$,,'
+ echo $(scriptname_to_command $cmd)
done
exit 0
fi
diff --git a/nix-script-diff-generations.sh b/nix-script-diff-generations.sh
index dd3945d..f16f90e 100755
--- a/nix-script-diff-generations.sh
+++ b/nix-script-diff-generations.sh
@@ -4,14 +4,14 @@ source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh
usage() {
cat <<EOS
- diff-generations [options] <generation a> <generation b>
+ $(help_synopsis "${BASH_SOURCE[0]}" "[-s | -u] [-n <a..b>] [-h]")
-s Use system generation for diffing
-u Use system generation for diffing
-n a..b Diff these generations
- -v Be verbose
-h Show this help and exit
+$(help_end)
EOS
}
diff --git a/nix-script-ls-profiles.sh b/nix-script-ls-profiles.sh
index 778ea7d..9cfc74d 100755
--- a/nix-script-ls-profiles.sh
+++ b/nix-script-ls-profiles.sh
@@ -6,14 +6,15 @@ profiledir=/nix/var/nix/profiles
usage() {
cat <<EOS >&2
- ls-profiles <--system|-s> <--user|-u> <--system-profiles|-p> <-v> <-h>
+ $(help_synopsis "${BASH_SOURCE[0]}" "[--system | -s] [--user | -u] [-n] [-h]")
--system | -s | Show system profiles
--user | -u | Show user profiles
--system-profiles | -p | Show other system profiles
-n | Show only profile numbers
- -v | Be verbose
-h | Show this help and exit
+
+$(help_end)
EOS
}
diff --git a/nix-utils.sh b/nix-utils.sh
index 6df996e..98fd94b 100644
--- a/nix-utils.sh
+++ b/nix-utils.sh
@@ -12,3 +12,20 @@ stdout() {
[ $VERBOSE -eq 1 ] && echo -e "${Green}[$(basename $0)]:${Color_Off} $*"
}
+scriptname_to_command() {
+ echo "$1" | sed 's,^\.\/nix-script-,,' | sed 's,\.sh$,,'
+}
+
+help_synopsis() {
+ SCRIPT=$(scriptname_to_command $1); shift
+ echo "usage: nix-script $SCRIPT $*"
+}
+
+help_end() {
+ echo -e "\tAdding '-v' before the '$1' command turns on verbosity"
+ echo -e ""
+ echo -e "\tReleased under terms of GPLv2"
+ echo -e "\t(c) 2015 Matthias Beyer"
+ echo ""
+}
+