bash_completion.pl: defaultFormatter v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 18 Aug 2015 23:37:22 +0200
branchv_0
changeset 2225ffeb18b6f85
parent 221 e38910065d55
child 223 195d969a1fb1
bash_completion.pl: defaultFormatter
scripts/bash_completion.pl
     1.1 --- a/scripts/bash_completion.pl	Sun Aug 16 01:40:44 2015 +0200
     1.2 +++ b/scripts/bash_completion.pl	Tue Aug 18 23:37:22 2015 +0200
     1.3 @@ -39,6 +39,7 @@
     1.4  
     1.5  my $databasesFile  = "$configDir/bash-completion/databases";
     1.6  my $formattersFile = "$configDir/bash-completion/formatters";
     1.7 +my $defaultFormatterFile = "$configDir/bash-completion/default-formatter";
     1.8  my $formatterPropertiesDir = "$configDir/bash-completion/formatter-properties";
     1.9  
    1.10  print '#have sql-dk &&
    1.11 @@ -47,12 +48,17 @@
    1.12  	for token in "$@"; do
    1.13  		if [ "x$previous" == "x--formatter" ]; then
    1.14  			echo -n "$token";
    1.15 +			return 0;
    1.16  		fi
    1.17  		previous="$token";
    1.18  	done
    1.19 +	
    1.20 +	if [ -f '.$defaultFormatterFile.' ]; then
    1.21 +		cat '.$defaultFormatterFile.'
    1.22 +	fi
    1.23  }
    1.24  
    1.25 -_sql_dk_bash_completion_formatter_property() {
    1.26 +_sql_dk_bash_completion_formatter_property_name() {
    1.27  	if [ -n "$formatter" ]; then # TODO: this does not match formatter name in apostrophes or quotes
    1.28  		local formatter_dir='.$formatterPropertiesDir.'/$formatter
    1.29  		if [ -d  $formatter_dir ]; then
    1.30 @@ -105,7 +111,7 @@
    1.31  		;;
    1.32  	--formatter-property)
    1.33  		formatter=$( _sql_dk_bash_completion_find_formatter "${COMP_WORDS[@]}" );
    1.34 -		COMPREPLY=( $( compgen -W "$(_sql_dk_bash_completion_formatter_property )" -- $cur ) ); 
    1.35 +		COMPREPLY=( $( compgen -W "$(_sql_dk_bash_completion_formatter_property_name )" -- $cur ) ); 
    1.36  		return 0;
    1.37  		;;
    1.38  	esac;