diff --git a/scripts/scripts/--help b/scripts/scripts/--help new file mode 100755 index 0000000..6ef54a9 --- /dev/null +++ b/scripts/scripts/--help @@ -0,0 +1,2 @@ +#!/bin/zsh + diff --git a/scripts/scripts/-h b/scripts/scripts/-h new file mode 100755 index 0000000..6ef54a9 --- /dev/null +++ b/scripts/scripts/-h @@ -0,0 +1,2 @@ +#!/bin/zsh + diff --git a/scripts/scripts/newx b/scripts/scripts/newx index 682970d..aefb1d2 100755 --- a/scripts/scripts/newx +++ b/scripts/scripts/newx @@ -5,17 +5,37 @@ declare -a localOpt declare -a functionOpt declare -a shellOpt=("zsh") +declare -a helpOpt DEBUG="$(env | grep DEBUG)" zparseopts -D -K -- \ {l,-local}+:=localOpt \ {f,-function}+:=functionOpt \ - {s,-shell}+=shellOpt + {s,-shell}+=shellOpt \ + {h,-help}=helpOpt shell=${shellOpt[-1]} localPath=${localOpt[-1]} #-------------------- Helpers -------------------- +function usage() { + cat << EOF +newx: Create new executable (script, function, or local script). + +Typical usage: + + newx foo (creates new script named 'foo') + +Usage: newx [-l ] [-f ] [-s ] + + -l | --local : Create a script in current directory. + -f | --function : Create a function. + + Advanced options: + -s | --shell : Customize the shell for the script. +EOF + +} function debug_print() { [ -n "$DEBUG" ] \ @@ -46,6 +66,10 @@ function parse_local_path() { debug_print "first-arg: $1" +if [ -n "${helpOpt}" ]; then + usage && exit 0 +fi + if [ -n "${functionOpt[-1]}" ]; then debug_print "function-opt: $functionOpt"