make --new accept --edit to init script from args and then edit
3 files changed, 15 insertions(+), 4 deletions(-)
M functions/__scriptura_new.fish → functions/__scriptura_new.fish
@@ -1,5 +1,7 @@ -function __scriptura_new --argument-names target - set --function remaining $argv[2..-1] +function __scriptura_new + argparse e/edit -- $argv + set --function target $argv[1] + set --function remaining $argv[2..] if not path is --type dir (path dirname $target) mkdir -p (path dirname $target)@@ -13,7 +15,7 @@ printf "%s\n%s\n" "#!/usr/bin/env fish" "$remaining" >$target chmod +x $target - if test (count $remaining) -eq 0 + if test (count $remaining) -eq 0; or set --query _flag_edit __scriptura_edit $target end end
M functions/scriptura.fish → functions/scriptura.fish
@@ -55,7 +55,7 @@ return $status end if set --query _flag_new - __scriptura_new $target $remaining + __scriptura_new $_flag_edit $target $remaining return $status end
M tests/scriptura.fish → tests/scriptura.fish
@@ -105,6 +105,15 @@ path is --type file --perm exec "$test_root/new_script" tail -n 1 "$test_root/new_script" ) = "echo foo" +# Test: --new --edit with -- creates script with remaining arguments +@test "--new --edit with -- creates script with remaining arguments" ( + set --global --export SCRIPTURA_ROOT $test_root + set --global --export SCRIPTURA_EDITOR "sed -i s/foo/bar/" + scriptura --new --edit new_edit_script -- echo foo + path is --type file --perm exec "$test_root/new_edit_script" + tail -n 1 "$test_root/new_edit_script" +) = "echo bar" + # Test: --which shows path for executable script @test "--which shows path for executable script" ( set --global --export SCRIPTURA_ROOT $test_root