diff --git a/.config/fish/functions/catall.fish b/.config/fish/functions/catall.fish index 6fe24ce..772780e 100644 --- a/.config/fish/functions/catall.fish +++ b/.config/fish/functions/catall.fish @@ -1,13 +1,18 @@ function catall --description "Print recursively multiple files." + # Declare our arguments + argparse h/help n/noheader -- $argv + # Get function name set current_name $(status current-function) - # Check if no arguments were provided, or if the first argument is '--help' - if test -z $argv[2] || test "$argv[1]" = --help || test "$argv[1]" = -h + # Check if not enough arguments provided, or help menu + if set -ql _flag_help || test -z $argv[2] echo -e "Usage: $current_name exts ..." echo -e " $current_name [-h|--help] \t\t\t - Show this help message" echo -e " $current_name *.c \t\t - Cat all .C files" echo -e " $current_name *.c *.h ... \t - Cat .C and .H files, etc." + echo -e "Flag:" + echo -e " [-n|-noheader] \t\t\t - Don't show the filenames before print" return 0 end @@ -21,7 +26,10 @@ function catall --description "Print recursively multiple files." end # Extra args for better printing - set args -exec echo -e "File: {}" \; -exec cat {} \; -exec echo "" \; + if not set -ql _flag_noheader + set args -exec echo -e "File: {}" \; + end + set -a args -exec cat {} \; -exec echo "" \; # Print files find $directory \( $exts \) $args