Commit Graph

119 Commits

Author SHA1 Message Date
Vladimir Zhelezov
deb2a27e45 Rebuild completion after the rebase on upstream/master
* `help` command's output is no longer listing help topics, so
those completions are removed.
* `check` command supersedes `check-dates`, `check-dupes`, etc.
2021-02-28 08:36:42 +01:00
Vladimir Zhelezov
066fa964b6 Disable shell expansion in here-docs
Better be safe that sorry...
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
3d3cd2d4a2 Makefile: move all variable definitions to the top, before targets 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
36fca65404 README: fix syntax highlighting, quotes 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
3ab796fd9e Update README 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
3c4025ae19 BSDmakefile
Just print a reminder to use `gmake` instead of spurting a bunch
of errors.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
419817e656 Prevent unwanted m4 macro expansion + -g GNU compatibility flag
Most of the included files are meant to be output literally, without any
macro processing. Using `undivert` in place of `include` achieves that.
This is a safety net against unsanitized input generated during the
build. Also, developers editing the shell code stub shouldn't be
constantly alert about triggering accidental macro expansion.

In order that `undivert` mimics GNU behaviour on BSDs, the `-g` flag is
used for the m4 invocation.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
2e44fe9e90 Portability: replace GNU extension \s with [[:space:]] 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
2a37479d60 Revert "Do not use set -e in helper shell scripts"
This reverts commit 0aeb88e663b9b19e173de20b132bef2189c6d7c9.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
0ca63ddc84 Install/uninstall completion for all extensions by default
Install the symlinks unconditionally. This way the user don't need
to reinstall completion after adding an extension. Of course fine-
grained control is possible with: `make install EXTENSIONS=web` e.g.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
62c3c8e6da Exit build with an error if unable to parse hledger sub-commands 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
ac143aff6b Do not use set -e in helper shell scripts
It is not a substitute for proper error checking, it can easily cause
more trouble than good and it would be a burden for contributors and a
source for potential misbehavior. See this take on the topic for
example: http://mywiki.wooledge.org/BashFAQ/105
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
dea35043bd Add phony clean-all build target
A `make clean` before commit removes hledger-completion.bash and
it is supposed to be in the repository. `make clean` removes build
artifacts while keeping the latter. Do a `make clean-all` to purge
everything.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
0bb4d1a6eb Remove api from hledger extensions
Superseded by hledger-web
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
b53e264da1 Update .gitignore
Options/commands parsing no longer creates any temporary files
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
9e90d25cce Add basic editor configuration to shell scripts 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
5c2dd6fa2f Move back commands/options parsing to separate shell scripts
It made the Makefile more difficult to read and this way we can
take advantage of `set -e`, `-o pipefail` and friends.

Clean up debugging targets
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
effb1be0e6 Avoid hard-coded reference to commands.tmp 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
b3f0b437a5 Add example usage comment for debug targets 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
84a7a66753 Modify .gitignore
query-filters.txt is a build dependency and shouldn't be ignored.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
b97c2043b8 Add install and uninstall build targets 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
1b6f968a6a Move commands and options parsing into the Makefile
It is just a pipe of sed regex filters and all can be viewed/edited
in one place. Add a couple of debug targets to see easily the
effects of regex changes.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
0498b8ff7c Add stub file to m4 build target prerequisites
And as it becomes unwieldy, put all the dependencies in a variable
2021-02-28 08:33:18 +01:00
Caleb Maclennan
4a32ebf8b5 Eliminate dependency on ‘paste’ and ‘parallel’ 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
bb8118c771 Isolate shell code in a stub file included by m4
This way we can easily edit m4 in m4-mode and the shell script stub
in sh-mode and prevent subtle errors coming from accidental quoting
issues or macros (mis)interpreted by m4.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
bc66b23520 Fix build race condition
Make `command-options` a prerequisite of `hledger-completion.bash`.
Currently the build succeeds only because the former takes less time
to finish than all the prerequisites of the latter. If you run a
`make clean && make -j 4`, the build would fail as they are built
in parallel.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
13bf6fdcd8 Amend installation comment 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
bee666704b Add a comment with example installation instructions 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
99af527f16 Remove _function from function names 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
fdac46d68a Fix _hledger_extension_completion when called by path...
Could break if called with ./funky-path/with-dashes/hledger-ui
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
fb3577d3e0 return 0
Shame on me...
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
910e86b4b2 Fix a7dc62d: set $subcommandOptions unconditionally 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
d82e13bb51 Add an automatic check for required option argument
Get rid of manually listing unhandled long options:

Instead of listing options requiring an argument one by one in the
case statement in _hledger_compreply_optarg(), the option completion
lists are searched and if the option does require an argument an
empty COMPREPLY is send. Short options are uncounted for and still
need a manual entry.

This necessitated setting $subcommandOptions beforehand, so it is
moved back where it was -- in the sub-command loop in main().
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
3eccfb85e0 Remove compopt -o nospace from --{close,open}-acct handler 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
0f8c01f033 Delay setting compopt -o filenames
...until just before query completion. It is not desired for
commands and options completion and is better used selectively
only when really needed.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
34dbe3b3a8 Use compopt -o nospace only for a query prefix
Similarly to long options treatment, suspend space only when
completing what looks like a query or account prefix i.e. something
ending with a colon (:).
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
797301c3dc White space 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
78ce651531 White space, fix alignment 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
1bbf04d310 Edit comments 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
05d483494b Remove redundant call of _get_comp_words_by_ref() 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
750450915d Break overly long lines for better readability
Hopefully differences are aligned and easily discernible this way
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
83cfd104f9 Remove _hledger_quote(), unused. 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
3cabee2470 Remove unnecessary quoting, a matter of consistency... 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
eea7f0d506 Add an early return from option argument completion
Do not even enter the case statement if preceding words don't look
like an option
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
b6a4a887b9 White space 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
046421e712 Simplify sub-command loop logic
If the cursor is on the sub-command, just offer sub-command
completions and be done with it. It was way over complicated.
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
f5d2a6bcc3 Move sub-command options reply out of the for-loop
It was just before the `break` statement anyways
2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
e2b2c2fb2e _hledger_compreply_query: minor refactor 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
0361c81da2 Add a couple of sub-commands to the no-query list 2021-02-28 08:33:18 +01:00
Vladimir Zhelezov
3a20e91b69 Further refinement of option extraction regex 2021-02-28 08:33:18 +01:00