9 Commits

Author SHA1 Message Date
Robin Jarry
d7cdaf1977 patch: use subcommand descriptions in completion items
go-opt v2.2.0 now supports providing individual descriptions for
completion items by appending a newline character to the completion item
followed by its description.

Do that for patch sub commands. Here's what it looks like:

       apply    (Apply the selected message(s) to the current project.)
       cd       (Change aerc's working directory to the current project.)
       drop     (Drop a patch from the repository.)
       find     (Search for applied patches.)
       init     (Create a new project.)
       list     (List the current project with the tracked patch sets.)
       ls       (List the current project with the tracked patch sets.)
       rebase   (Rebase the patch data.)
       switch   (Switch context to the specified project.)
       term     (Open a shell or run a command in the current project's directory.)
       unlink   (Delete all patch tracking data for the specified project.)
:patch

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Antonin Godard <antonin@godard.cc>
2025-11-17 09:51:00 +01:00
Robin Jarry
713e8a03f2 commands: quote and add space to completions by default
Instead of duplicating commands.QuoteSpace almost everywhere, make it
the default value for the post processing function of FilterList.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Antonin Godard <antonin@godard.cc>
2025-11-17 09:51:00 +01:00
Robin Jarry
0738794671 patch: complete subcommands in alphabetical order
Instead of printing completion items for patch sub commands in a random
order (depending on whatever go hash table seed is used), sort the
completion items using standard ASCII order.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Antonin Godard <antonin@godard.cc>
2025-11-17 09:51:00 +01:00
Robin Jarry
adf2b88059 patch: fix subcommand argument parsing
Since go-opt v2, the flags from subcommands are not interpreted
properly. This has been reported on several occasions.

go-opt now supports sub-commands natively. Update the code accordingly.

Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CDAY90JZ9MOIG.1C9R23VEAHUKC@godard.cc%3E
Link: https://lists.sr.ht/~rjarry/aerc-discuss/%3CDE7WHEYWRTKG.34X7GON6NRBI7@mervyn.online%3E
Reported-by: Antonin Godard <antonin@godard.cc>
Reported-by: Mervyn Fox <dev@mervyn.online>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Antonin Godard <antonin@godard.cc>
2025-11-17 09:51:00 +01:00
Robin Jarry
d0484b153a completion: add command option descriptions
Add `desc:""` struct field tags in all command arguments where it makes
sense.

The description values will be returned along with completion choices.

Implements: https://todo.sr.ht/~rjarry/aerc/271
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bojan Gabric <bojan@bojangabric.com>
Tested-by: Jason Cox <me@jasoncarloscox.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2024-10-23 10:22:51 +02:00
Robin Jarry
26033eaecf completion: add commands descriptions
Update the Command interface to include a Description() method.
Implement the method for all commands using short descriptions inspired
from the aerc(1) man page.

Return the description values along with command names so that they can
be displayed in completion choices.

Implements: https://todo.sr.ht/~rjarry/aerc/271
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bojan Gabric <bojan@bojangabric.com>
Tested-by: Jason Cox <me@jasoncarloscox.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2024-10-23 10:22:51 +02:00
Robin Jarry
3c9ad93801 completion: display descriptions next to choices
Use go-opt v2 new completion API which returns items descriptions along
with their text values.

Display the descriptions after the items separated by two spaces. Wrap
the descriptions in parentheses to better indicate that they are not
part of the completion choices. Limit the description length to 80
characters to avoid display issues.

Add a new style object completion_description in stylesets. By default,
the object will be rendered with a dimmed terminal attribute. Update all
stylesets and documentation accordingly.

Implements: https://todo.sr.ht/~rjarry/aerc/271
Link: https://git.sr.ht/~rjarry/go-opt/commit/ebeb82538395a
Changelog-added: Command completion now displays descriptions next
 to completion items.
Changelog-added: New `completion_description` style object in style
 sets used for rendering completion item descriptions.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bojan Gabric <bojan@bojangabric.com>
Tested-by: Jason Cox <me@jasoncarloscox.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
2024-10-23 10:22:51 +02:00
Robin Jarry
159fb38daf commands: refactor registration
Register all commands with the same function and store them in the same
map.

Use bit flags to determine in which contexts each command should be
available.

Remove duplicate commands now that the same command can be exposed in
multiple contexts.

Refactor API to allow executing commands from other commands without
import cycles.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Tested-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
2024-01-20 21:56:25 +01:00
Koni Marti
07c1cefcf6 patch: create sub-command structure
Create the sub-command structure for the :patch command. Make the :patch
command accessible from any context.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2023-12-30 15:42:09 +01:00