From decae1b9a83eaa46526437e88d249d9855421e38 Mon Sep 17 00:00:00 2001 From: Les De Ridder Date: Sun, 24 Mar 2019 08:52:12 +0100 Subject: [PATCH] Make colour output configurable and output spaces instead of tabs --- saury | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/saury b/saury index fe6f970..085e747 100755 --- a/saury +++ b/saury @@ -42,14 +42,16 @@ end function print_usage function print_operation - echo -e "\t"(status -f) $argv + echo -e " "(status -f) $argv end - echo 'usage:' (status -f) ' [...]' + echo 'usage:' (status -f) '[options] [...]' echo 'operations:' print_operation "{-h --help}" print_operation "{-V --version}" print_operation "{-A --aur-sync} [options] [package(s)]" + echo 'options:' + echo ' --color ' end function print_version @@ -118,7 +120,7 @@ function aur_search echo set_color normal - echo \t$description + echo " $description" end else if test "$rpc_response_type" = "error" set rpc_error (echo $rpc_response | jq -r '.error') @@ -134,8 +136,6 @@ function aur_sysupgrade end function on_start - tabs -4 - # Detect 24-bit colour support # (Source: https://github.com/fish-shell/fish-shell/blob/619a248a3525b13ccd12f815cdb2d373e7372292/share/config.fish#L18) if not set -q STY @@ -158,10 +158,6 @@ function on_start end end -function on_exit - tabs -8 -end - function main set -le argv @@ -169,7 +165,7 @@ function main set aur_sync_exclusive_options 's,u' argparse -n $saury_name -x 'V,A' -x $aur_sync_exclusive_options \ - 'h/help' 'V/version' 'A/aur-sync' $aur_sync_options -- $argv \ + 'h/help' 'V/version' 'A/aur-sync' 'c-color=?' $aur_sync_options -- $argv \ ^| sed (string join '' 's/:/:' (set_color red) '/;s/$/' (set_color normal) '/') | head -1 if not set --local --query argv @@ -177,6 +173,15 @@ function main exit 1 end + if set --query _flag_color + if test "$_flag_color" = "always" + functions -e set_color + else if test "$_flag_color" = "never" + function set_color + end + end + end + if set --query _flag_help print_usage else if set --query _flag_version @@ -200,4 +205,3 @@ end on_start main $argv -on_exit