Commit graph

71 commits

Author SHA1 Message Date
Juerd Waalboer
d54428b092 Add support for user-accessible accounts that are excluded from grandtotal 2023-11-02 05:33:33 +01:00
Juerd Waalboer
df8c84672d tail/users: fix warning when used with old log files 2023-11-02 04:45:03 +01:00
Juerd Waalboer
1156864fd2 v4.1.0
- New internal feature: $plugin->Tab($method)
- `adduser` has an additional check
- Tiny bug fixes
2023-11-02 04:39:57 +01:00
Juerd Waalboer
8956d8a483 Move :Tab introspection from main:: to RevBank::Plugin
- Exposes the introspection as a public method.
- Removes undocumented support for NOABORT special-case.
2023-11-02 03:16:55 +01:00
Juerd Waalboer
560242a4bc Bump version to 4.0.0; change transaction ID scheme 2023-09-20 20:15:43 +02:00
Juerd Waalboer
fbb178d5ac Formal mechanism for retrying input
This allows for alias plugins with better error messages and better
logging than with the $_[2] =~ s/// hack.
2023-09-18 01:31:13 +02:00
Juerd Waalboer
6f110ee783 Update shebang to use /usr/bin/env 2023-08-21 03:43:52 +02:00
Juerd Waalboer
459e5619a7 Place cursor at start of rejected input instead of end
The cursor was placed after the rejected input, both to indicate where
the mistake was, and to make it easy to <backspace> it out. But since
"retry" is only used when there are trailing words, that means the
cursor would be placed on the space between the mistake and the trailing
input. By putting it at the first character of the rejected input, it
is less visually ambiguous. The user can now use <delete> instead of
<backspace>.
2023-07-12 22:12:30 +02:00
Juerd Waalboer
06d4591e8a Fix tab completion bug
When there were several matches that shared the same common prefix, but
with a different case, readline would eat the input from the case
sensitive longest common prefix up to where the case began to differ.

e.g. when "ibutton" and "iButton-touwtje" were available, typing
"ibu<tab>" would truncate the input to just "i" and on second tab show
both matches, but without ever completing beyond the "i".
2023-02-22 01:39:13 +01:00
Juerd Waalboer
fffb2d72e9 Fix deduplication bug, refactor deduplication to own plugin
(Bumps version to 3.8 because admins should update the plugin list.)

Deduplication didn't work on quantified additions, i.e. if you added
"20x clubmate" when there was already clubmate in the cart, it would add
just ONE item, and have a lingering message that the next thing would be
multiplied by 20.

This old bug was especially annoying if there is a barcode "20x
clubmate" to scan 20 bottles (which is the size of a crate), and this is
repeated.

The fix also uncovered another bug: newly added entries were selected
too early. There are two hooks, hook_add_entry and hook_added_entry, and
of course the selection should happen in between, not before the former.
No entry in UPGRADING.md, because I think it is extremely unlikely that
any plugin author will have used the selection feature yet, which is
very new.
2023-02-12 17:53:14 +01:00
Juerd Waalboer
9045eb7ff4 Don't tab complete invalid input
Products and users that begin with `+` are internal, as are users that
begin with `-`. These should be excluded from tab completion.
2023-01-30 17:19:50 +01:00
Juerd Waalboer
382940bfc9 Show unmodified input in error message 2023-01-30 06:12:23 +01:00
Juerd Waalboer
16d530ae16 Allow hook_prompt to mutate the prompt, like before, and use that
This functionality was accidentally broken by eed0db78

Also: ignore readline terminal sequence (\x01...\x02) in detection of ">"
2023-01-19 03:04:35 +01:00
Juerd Waalboer
50d93b3f6e v3.7
New core functionality (commit 11ca0a86) warrants new version number.
2023-01-16 03:18:06 +01:00
Juerd Waalboer
6089e212dc Release locks on abort
Fixes deadlock if hook_checkout returns ABORT.

One of these days I want to implement the abort mechanism through
exceptions, even though that means handling it explicitly in more
places. Or maybe *because* that means handling it explicitly in more
places.
2023-01-16 01:17:33 +01:00
Juerd Waalboer
da523f8daa v3.6: products overhaul
New features, new documentation.
2022-12-25 05:32:00 +01:00
Juerd Waalboer
4c380a8ac4 Fix bug in REJECT handling
Next input would not be split.

    > withdraw 1
    Pending:
	1.00 Withdrawal
    Enter username to deduct 1.00 from your account; type 'abort' to abort.

    > undo
    Undo is not available mid-transaction. Enter 'abort' to abort.
    > undo 123
    undo 123: No such product, user, or command.

Of course, "undo 123" as top-level input should have been split on
whitespace.

Top-level input is handled by the 'command' method, so that should be a
reliable way to detect that the prompt is a top-level prompt, rather
than a follow-up prompt. Keeping an additional global boolean was a dumb
approach anyway.
2022-08-30 22:50:04 +02:00
Juerd Waalboer
43a1990974 bump to v3.5; add built-in editor 2022-08-30 20:45:01 +02:00
Juerd Waalboer
441bf05fde Bump to v3.4; make all transactions balanced using hidden accounts
See UPGRADING.md for details.
2022-06-11 18:51:26 +02:00
Juerd Waalboer
f262bce57c Split "help" into "help" and "help2"; ditch pager 2022-06-11 16:31:44 +02:00
Juerd Waalboer
a7a5f14e0c Introduce 'withdraw', remove "withdrawal or unlisted" feature.
This should have been done much earlier, but wasn't done for nostalgic reasons.
To new users, it didn't make sense that you could just enter an amount, and
revbank would just accept that as "withdrawal or unlisted product". It existed
for backwards compatibility with the very first revbank version, which didn't
have a product list, and which was not yet used with a barcode scanner. You
would simply enter the amount and your name, and there were no further
statistics.

Nowadays, there are statistics that are messed up if you don't use the product
codes. And some people were looking for a withdrawal command, and try 'take' as
that seems closest to it, but which instead transfers money to another account.

Additionally, some texts were changed for improved clarity. ("Enter username to
pay", when withdrawing, was confusing: one expects money back, not to pay more.)
2022-06-04 02:41:17 +02:00
Juerd Waalboer
eed0db7897 Cleanup: use subroutine signatures, remove deprecated methods.
The signatures feature has been "experimental" since Perl 5.20 (May 2014), but
expected to stay. After 8 years I'm ready to take the risk :)

Have added Perl v5.28 (June 2018) as the minimum requirement, even though the
current revbank should work with 5.20, to see if this bothers any users. Perl
v5.28 is in Debian "buster", which is now oldstable.
2021-12-03 18:00:34 +01:00
Juerd Waalboer
38a0229899 Ditch floating point numbers, use cents instead; bump version to 3.2 2021-12-02 22:18:06 +01:00
Juerd Waalboer
df771e22fd Fix bug where follow-up prompt of second command would split on whitespace
Bug:

    > 2x unlisted 6
    Please provide a short description: bar foo
    foo: No such product, user, or command.

Fixed:

    > 2x unlisted 6
    Please provide a short description: bar foo
    Pending:
    2x {
        6.00 bar foo
    }
    Enter username to pay 12.00; type 'abort' to abort.
2020-09-07 02:27:25 +02:00
Juerd Waalboer
f312b31576 Fix POD/markdown 2020-06-10 21:05:20 +02:00
Juerd Waalboer
c3b0b86c97 No tab-completion for empty input
Old terminal takes about 1 minute to scroll the >9000 options...
2019-11-08 03:44:19 +01:00
Juerd Waalboer
da043ba2df New plugin: beep on error
If you computer beeps, that is. Most revbank setups run on raspberry pi's,
which don't beep...
2019-11-08 03:41:49 +01:00
Juerd Waalboer
5840b7bbac Tiny refactor 2019-11-06 19:23:44 +01:00
Juerd Waalboer
464a6db78c Whitespace tweaks (newlines)
Consistency: empty line before each prompt, but not after.
2019-11-06 19:13:12 +01:00
Juerd Waalboer
bb8c52b593 Do provide final cart when no pending cart was ever shown... 2019-11-06 06:13:18 +01:00
Juerd Waalboer
c9b704adca Make ">" prompt green 2019-11-05 06:16:54 +01:00
Juerd Waalboer
60f413eb73 Change main prompt to "> ".
This shifts the reader's focus to the messages from plugins, such as the
instruction to enter your username to pay.

It also looks nicer next to the new cleaner transaction overviews.
2019-11-05 03:14:41 +01:00
Juerd Waalboer
a16348055f Bump version to 3 :) 2019-11-05 02:04:12 +01:00
Juerd Waalboer
9e5ac6eb06 Update documentation on deprecations 2019-11-05 01:36:21 +01:00
Juerd Waalboer
735009a02d Remove deprecated plugins 'nyan' and 'game' 2019-11-04 19:43:51 +01:00
Juerd Waalboer
d8dfc2cde2 Retry after REJECT: edit bad input instead of aborting 2019-11-03 00:13:43 +01:00
Juerd Waalboer
0baa40b910 Ditch minor part of version number 2019-07-02 04:40:08 +02:00
Juerd Waalboer
9f905b84d5 Abort transaction on SIGINT 2019-07-02 04:38:21 +02:00
Juerd Waalboer
cac85bc6bf Fix indent 2019-06-07 01:25:29 +02:00
Juerd Waalboer
da11114b8f Deprecate nyan, game, and creating users via deposit. 2019-05-15 01:41:27 +02:00
Juerd Waalboer
28e45dc8a2 Document console font requirement for QR code 2019-05-12 22:41:11 +02:00
Juerd Waalboer
4eb3f8ce20 Re-add history feature
Was originally added in 2015 (commit bb8652f4ac89a7453394020a472279809413d10f),
but the line and the commit are nowhere to be found. It may have been lost in
a git merge.
2019-03-14 01:30:35 +01:00
Juerd Waalboer
3ce1874d3a Reset idle timer on character input
Requested by peterbjornx
2018-03-23 01:21:25 +01:00
Juerd Waalboer
b22f281938 Shell-like '-c' for non-interactive commands 2017-03-12 21:19:21 +01:00
Juerd Waalboer
add3100401 New plugin: repeat (undocumented), new hook: "added" 2017-02-19 00:41:20 +01:00
Juerd Waalboer
b0ee7e88bf cwd is no longer in @INC in new perl versions 2017-02-18 22:31:19 +01:00
Juerd Waalboer
8f84891b0c Warn when someone leaves without paying. 2014-01-10 21:20:21 +01:00
Juerd Waalboer
7b088cb175 Tab completion improvements
A plugin can now specify &subroutine in the :Tab attribute; this sub will
be called as a method and can return a list of possible completions.
2013-02-28 16:04:36 +01:00
Juerd Waalboer
c157ea0214 RevBank 2.0, a rewrite. It's plugin based now. 2013-02-26 04:11:13 +01:00
RevBar
478c93cbeb Change 'take' prompt and strip whitespace from input 2011-06-10 01:31:46 +02:00