dotfiles/swim

75 lines
1.4 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env -S fish --private
set general_help '
A collection of useful functions for this project.
Either run a function like ./swim.fish <function> [arg [arg [...]]
or source the file and run them as commands:
$ source ./swim.fish
$ lint [args]
Run ./swim help <function_name> to see it\'s definition.
'
# Configuration
set src_fish_files \
./install_arch \
./provision_linux \
./sync \
./upgrade_debian \
./**.fish \
./.**.fish
# Commands
function lint -d 'Lint fish scripts'
fish --no-execute $src_fish_files
end
function format -d 'Format fish scripts'
fish_indent --write $src_fish_files
end
function sync -d 'Run the sync script'
./sync $argv
end
function install_arch -d 'Run the install_arch script'
./install_arch $argv
end
function upgrade_debi -d 'Run the debian_upgrade script'
./upgrade_debian $argv
end
function provision -d 'Run the provision_linux script with the specified distro'
argparse 'd/distro=' -- $argv
if test -n "$_flag_d"
set -g distro $_flag_d
end
./provision_linux $argv[2..-1]
end
# --- execution/help handling ---
function help -a function_name -d 'Displays help for internal function'
if test -n "$function_name"
functions $function_name
else
echo $general_help
end
end
argparse --ignore-unknown h/help -- $argv
if test -n "$_flag_h"
help $argv
else if test -n "$argv"
$argv
else
echo $general_help
end