print which variable was used to define SCRIPTURA_ROOT
3 files changed, 22 insertions(+), 19 deletions(-)
changed files
D functions/__scriptura_usage.fish
@@ -1,6 +0,0 @@ -function __scriptura_usage - echo "Usage: $(status current-command) [run] <script_name>" - echo "SCRIPTURA_ROOT: $SCRIPTURA_ROOT" - echo "" - __scriptura_list $SCRIPTURA_ROOT -end
M functions/scriptura.fish → functions/scriptura.fish
@@ -1,26 +1,35 @@ -if not set --query SCRIPTURA_ROOT - if set --query SD_ROOT - set --global SCRIPTURA_ROOT $SD_ROOT - else - set --global SCRIPTURA_ROOT "$HOME/sd" +function scriptura + set --function valid_subcommands run help new edit which cat + + if not set --query --function scriptura_root_var + if not set --query SCRIPTURA_ROOT; and set --query SD_ROOT + set --function scriptura_root_var SD_ROOT + else + set --function scriptura_root_var SCRIPTURA_ROOT + end end -end -function scriptura - set --function valid_subcommands run help new edit which cat + set --function SCRIPTURA_ROOT $$scriptura_root_var + if test -z "$SCRIPTURA_ROOT" + set --function SCRIPTURA_ROOT $HOME/sd + end if not path is $SCRIPTURA_ROOT if test "$argv[1]" = new mkdir $SCRIPTURA_ROOT return 0 else - echo \$SCRIPTURA_ROOT $SCRIPTURA_ROOT does not exist, use `$(status function) new` to create it + echo $scriptura_root_var $SCRIPTURA_ROOT does not exist, use `$(status function) new` to create it return 1 end end if not count $argv >/dev/null - __scriptura_usage $valid_subcommands + printf 'Usage: %s [run] <script_name>\n' (status current-command) + printf '%s: %s\n' $scriptura_root_var $SCRIPTURA_ROOT + printf '\n' + + __scriptura_list $SCRIPTURA_ROOT return 0 end
M tests/scriptura.fish → tests/scriptura.fish
@@ -27,7 +27,7 @@ set --erase SCRIPTURA_ROOT set --erase SD_ROOT source $(status dirname)/../functions/scriptura.fish scriptura -) = "\$SCRIPTURA_ROOT $HOME/sd does not exist, use `scriptura new` to create it" +) = "SCRIPTURA_ROOT $HOME/sd does not exist, use `scriptura new` to create it" # Test: SCRIPTURA_ROOT uses SD_ROOT when set @test "SCRIPTURA_ROOT uses SD_ROOT when set" (@@ -35,7 +35,7 @@ set --erase SCRIPTURA_ROOT set --global --export SD_ROOT "/custom/sd" source $(status dirname)/../functions/scriptura.fish scriptura -) = "\$SCRIPTURA_ROOT /custom/sd does not exist, use `scriptura new` to create it" +) = "SD_ROOT /custom/sd does not exist, use `scriptura new` to create it" # Test: SCRIPTURA_ROOT uses existing value when set @test "SCRIPTURA_ROOT uses existing value when set" (@@ -43,7 +43,7 @@ set --global --export SCRIPTURA_ROOT "/existing/root" set --global --export SD_ROOT "/custom/sd" source $(status dirname)/../functions/scriptura.fish scriptura -) = "\$SCRIPTURA_ROOT /existing/root does not exist, use `scriptura new` to create it" +) = "SCRIPTURA_ROOT /existing/root does not exist, use `scriptura new` to create it" # Test: usage is shown when no arguments provided @test "usage is shown when no arguments provided" -n (