Created
September 20, 2024 18:51
-
-
Save bdmorin/0053a71039b751fb935ec4c244172f2b to your computer and use it in GitHub Desktop.
In response to: https://msamgan.com/boilerplate-for-creating-a-shell-script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env fish | |
# Strict Mode and Tracing | |
set -e | |
set -u | |
if set -q TRACE; and test "$TRACE" = 1 | |
set -x | |
end | |
# Help Message | |
if test (count $argv) -gt 0; and test $argv[1] = '-h' -o $argv[1] = '--help' | |
echo 'Usage: ./script.fish arg-one arg-two' | |
echo 'This is an awesome fish script to make your life better.' | |
exit | |
end | |
# Main Function | |
function main | |
echo do awesome stuff | |
end | |
# Completion | |
complete -c $PROGRAM_NAME -n '__fish_use_subcommand' -a 'arg-one' -d 'The first argument' | |
complete -c $PROGRAM_NAME -n '__fish_use_subcommand' -a 'arg-two' -d 'The second argument' | |
# Call main function with arguments | |
main $argv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment