Add completions for query filters
This commit is contained in:
		
							parent
							
								
									5df9de3abb
								
							
						
					
					
						commit
						3f407a326d
					
				| @ -3,7 +3,7 @@ | |||||||
| 
 | 
 | ||||||
| all: command-options hledger-completion.bash | all: command-options hledger-completion.bash | ||||||
| 
 | 
 | ||||||
| hledger-completion.bash: hledger-completion.bash.m4 commands-list.txt generic-options.txt | hledger-completion.bash: hledger-completion.bash.m4 commands-list.txt query-filters.txt generic-options.txt | ||||||
| 	m4 hledger-completion.bash.m4 > $@ | 	m4 hledger-completion.bash.m4 > $@ | ||||||
| 
 | 
 | ||||||
| generic-options.txt: | generic-options.txt: | ||||||
|  | |||||||
| @ -76,7 +76,8 @@ _hledger_completion_function() { | |||||||
| 	# be passed! | 	# be passed! | ||||||
| 
 | 
 | ||||||
| 	declare -a accounts | 	declare -a accounts | ||||||
| 	readarray -t accounts < <(hledger accounts --flat | grep "^$wordToComplete") | 	readarray -t accounts < <({ cat "$_HLEDGER_COMPLETION_TEMPDIR/query-filters.txt"; hledger accounts --flat; } | grep "^$wordToComplete") | ||||||
|  | 	compopt -o nospace | ||||||
| 	COMPREPLY+=( "${accounts[@]}" ) | 	COMPREPLY+=( "${accounts[@]}" ) | ||||||
| 	# Special characters (e.g. '-', ':') are allowed in account names. | 	# Special characters (e.g. '-', ':') are allowed in account names. | ||||||
| 	# Account names with spaces must be still be quoted (e.g. '"Expens') | 	# Account names with spaces must be still be quoted (e.g. '"Expens') | ||||||
| @ -128,6 +129,31 @@ cf | |||||||
| is | is | ||||||
| TEXT | TEXT | ||||||
| 
 | 
 | ||||||
|  | cat <<TEXT > "$_HLEDGER_COMPLETION_TEMPDIR/query-filters.txt" | ||||||
|  | not: | ||||||
|  | acct: | ||||||
|  | amt: | ||||||
|  | amt:< | ||||||
|  | amt:<= | ||||||
|  | amt:> | ||||||
|  | amt:>= | ||||||
|  | code: | ||||||
|  | cur: | ||||||
|  | desc: | ||||||
|  | date: | ||||||
|  | date2: | ||||||
|  | depth: | ||||||
|  | note: | ||||||
|  | payee: | ||||||
|  | real: | ||||||
|  | real:0 | ||||||
|  | status: | ||||||
|  | status:! | ||||||
|  | status:* | ||||||
|  | tag: | ||||||
|  | inacct: | ||||||
|  | TEXT | ||||||
|  | 
 | ||||||
| cat <<TEXT > "$_HLEDGER_COMPLETION_TEMPDIR/generic-options.txt" | cat <<TEXT > "$_HLEDGER_COMPLETION_TEMPDIR/generic-options.txt" | ||||||
| -f | -f | ||||||
| -I | -I | ||||||
|  | |||||||
| @ -76,7 +76,8 @@ _hledger_completion_function() { | |||||||
| 	# be passed! | 	# be passed! | ||||||
| 
 | 
 | ||||||
| 	declare -a accounts | 	declare -a accounts | ||||||
| 	readarray -t accounts < <(hledger accounts --flat | grep "^$wordToComplete") | 	readarray -t accounts < <({ cat "$_HLEDGER_COMPLETION_TEMPDIR/query-filters.txt"; hledger accounts --flat; } | grep "^$wordToComplete") | ||||||
|  | 	compopt -o nospace | ||||||
| 	COMPREPLY+=( "${accounts[@]}" ) | 	COMPREPLY+=( "${accounts[@]}" ) | ||||||
| 	# Special characters (e.g. '-', ':') are allowed in account names. | 	# Special characters (e.g. '-', ':') are allowed in account names. | ||||||
| 	# Account names with spaces must be still be quoted (e.g. '"Expens') | 	# Account names with spaces must be still be quoted (e.g. '"Expens') | ||||||
| @ -98,6 +99,10 @@ cat <<TEXT > "$_HLEDGER_COMPLETION_TEMPDIR/commands.txt" | |||||||
| include(`commands.txt')dnl | include(`commands.txt')dnl | ||||||
| TEXT | TEXT | ||||||
| 
 | 
 | ||||||
|  | cat <<TEXT > "$_HLEDGER_COMPLETION_TEMPDIR/query-filters.txt" | ||||||
|  | include(`query-filters.txt')dnl | ||||||
|  | TEXT | ||||||
|  | 
 | ||||||
| cat <<TEXT > "$_HLEDGER_COMPLETION_TEMPDIR/generic-options.txt" | cat <<TEXT > "$_HLEDGER_COMPLETION_TEMPDIR/generic-options.txt" | ||||||
| include(`generic-options.txt')dnl | include(`generic-options.txt')dnl | ||||||
| TEXT | TEXT | ||||||
|  | |||||||
							
								
								
									
										22
									
								
								shell-completion/query-filters.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								shell-completion/query-filters.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | |||||||
|  | not: | ||||||
|  | acct: | ||||||
|  | amt: | ||||||
|  | amt:< | ||||||
|  | amt:<= | ||||||
|  | amt:> | ||||||
|  | amt:>= | ||||||
|  | code: | ||||||
|  | cur: | ||||||
|  | desc: | ||||||
|  | date: | ||||||
|  | date2: | ||||||
|  | depth: | ||||||
|  | note: | ||||||
|  | payee: | ||||||
|  | real: | ||||||
|  | real:0 | ||||||
|  | status: | ||||||
|  | status:! | ||||||
|  | status:* | ||||||
|  | tag: | ||||||
|  | inacct: | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user