From f3d8897187d40c7e3482d6daeb805d8e1ddd0a2f Mon Sep 17 00:00:00 2001 From: mitchell Date: Thu, 29 Oct 2020 23:29:20 -0400 Subject: [PATCH] Modify repo to be installable via fisher --- importable_sw.fish => functions/sw.fish | 19 +++++++++++++++++++ sw | 24 +++++++++++++++--------- swim.fish => swim.fish.example | 2 +- 3 files changed, 35 insertions(+), 10 deletions(-) rename importable_sw.fish => functions/sw.fish (82%) rename swim.fish => swim.fish.example (98%) diff --git a/importable_sw.fish b/functions/sw.fish similarity index 82% rename from importable_sw.fish rename to functions/sw.fish index 7dbb0eb..96437c2 100644 --- a/importable_sw.fish +++ b/functions/sw.fish @@ -1,3 +1,22 @@ +function sw -d 'The fish-based project script runner' + argparse --ignore-unknown 'i-init' -- $argv + set -g cmd_func_prefix 'swim' + + if test -n "$_flag_init" + curl -fsS https://raw.githubusercontent.com/mitchell/swim.fish/master/swim.fish.example >swim.fish + return + end + + if test -f ./swim.fish + source ./swim.fish + else + echo 'No swim.fish found. Run `sw --init` make one.' + return 1 + end + + run_swim_command $cmd_func_prefix $argv +end + function run_swim_command -a prefix argparse --ignore-unknown 'h/help' -- $argv set -l command $argv[2] diff --git a/sw b/sw index 93d7669..ce9aab8 100755 --- a/sw +++ b/sw @@ -1,14 +1,20 @@ #!/usr/bin/env fish -set -g cmd_func_prefix 'swim' - -if test -f ./swim.fish - source ./swim.fish -else - echo 'No swim.fish found in current directory. Please copy the template from https://github.com/mitchell/swim.fish' - exit 1 -end - function main + argparse --ignore-unknown 'i-init' -- $argv + set -g cmd_func_prefix 'swim' + + if test -n "$_flag_init" + curl -fsS https://raw.githubusercontent.com/mitchell/swim.fish/master/swim.fish.example >swim.fish + return + end + + if test -f ./swim.fish + source ./swim.fish + else + echo 'No swim.fish found. Run `sw --init` make one.' + return 1 + end + run_swim_command $cmd_func_prefix $argv end diff --git a/swim.fish b/swim.fish.example similarity index 98% rename from swim.fish rename to swim.fish.example index 67acb5c..c2f43b3 100644 --- a/swim.fish +++ b/swim.fish.example @@ -73,5 +73,5 @@ function swim_fails -d 'This command fails every time' false end -#curl -fsS https://raw.githubusercontent.com/mitchell/swim.fish/master/importable_sw.fish | source +#curl -fsS https://raw.githubusercontent.com/mitchell/swim.fish/master/functions/sw.fish | source #run_swim_command $cmd_func_prefix $argv