diff options
Diffstat (limited to 'nix-script')
-rwxr-xr-x | nix-script | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -4,6 +4,7 @@ usage() { cat <<EOS >&2 $(help_synopsis "${BASE_SOURCE[0]}" "[options] <command> <commandoptions>") + --conf=<path> Path for alternative nix-script.rc file. Default: ~/.nix-script.rc -l | --list-commands List all available commands -v Be verbose -d Debugging output (enables -v) @@ -13,6 +14,7 @@ $(help_end) EOS } +RC=~/.nix-script.rc LIST_COMMANDS=0 VERBOSE=0 @@ -61,6 +63,13 @@ all_commands() { for cmd do case $cmd in + --conf=*) + RC=$(echo $cmd | sed 's,^--conf\=,,') + dbg "RC = $RC" + [[ ! -e $RC ]] && stderr "RC file '$RC' does not exist" && exit 1 + shift_one_more + ;; + "--list-commands" ) LIST_COMMANDS=1 shift_one_more @@ -106,6 +115,19 @@ do esac done +if [[ ! -f "$RC" ]] +then + dbg "No configuration file, setting up (empty) default values" + + RC_CONFIG="" + RC_NIXPKGS="" +else + source $RC +fi + +dbg "RC_CONFIG = '$RC_CONFIG'" +dbg "RC_NIXPKGS = '$RC_NIXPKGS'" + if [ $LIST_COMMANDS -eq 1 ] then dbg "Listing commands" |