aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg/pipe.go
Commit message (Collapse)AuthorAgeFilesLines
* treewide: replace uint32 uids with opaque stringsRobin Jarry2024-08-281-1/+2
| | | | | | | | | | | | | | | | | Add a new models.UID type (an alias to string). Replace all occurrences of uint32 being used as message UID or thread UID with models.UID. Update all workers to only expose models.UID values and deal with the conversion internally. Only IMAP needs to convert these to uint32. All other backends already use plain strings as message identifiers, in which case no conversion is even needed. The directory tree implementation needed to be heavily refactored in order to accommodate thread UID not being usable as a list index. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
* pipe: add -d flag to decrypt messageKoni Marti2024-08-201-0/+25
| | | | | | | | | | | Add -d flag to the pipe command to decrypt a message before it is piped. Implements: https://todo.sr.ht/~rjarry/aerc/238 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Jens Grassel <jens@wegtam.com> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* pipe: allow closing the terminal automaticallyJohannes Thyssen Tishman2024-04-131-1/+2
| | | | | | | | | | | | | Add a new -s flag to :pipe. When specified, the terminal tab opened by the :pipe command will be automatically closed after the process is completed instead of prompting for a key press. While this doesn't technically silence the command (the output is not suppressed), the output is not shown to the user. Changelog-added: Silently close the terminal tab after piping a message to a command with `:pipe -s <cmd>`. Signed-off-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: rename confusing constantsRobin Jarry2024-03-041-1/+1
| | | | | | | | There is an overlap between ACCOUNT and MESSAGE. Rename ACCOUNT to MESSAGE_LIST and use MESSAGE_LIST|MESSAGE_VIEWER instead of MESSAGE. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tim Culverhouse <tim@timculverhouse.com>
* log: move package to libRobin Jarry2024-02-141-1/+1
| | | | | | | This has nothing to do at the root of the source tree. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* commands: refactor registrationRobin Jarry2024-01-201-1/+5
| | | | | | | | | | | | | | | | | | 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>
* patch/apply: add apply sub-cmdKoni Marti2023-12-301-0/+16
| | | | | | | | | | Add the :patch apply command to apply a patch set and create a corresponding tag. The tag command argument can be completed based on the subject lines of the selected messages. Add a test for the completion proposal. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: use completion from go-optRobin Jarry2023-10-281-4/+0
| | | | | | | | | | | Implement command completion with complete struct field tags from the get-opt library introduced earlier. Changelog-changed: Improved command completion. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
* pipe: run commands with sh -cRobin Jarry2023-10-281-11/+14
| | | | | | | | | | | | Change the Cmd argument to a plain string that preserves shell quoting. Use this for sh -c instead of a list of arguments. Changelog-changed: `:pipe` commands are now executed with `sh -c`. Requested-by: Vitaly Ovchinnikov <v@postbox.nz> Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
* commands: parse arguments with go-optRobin Jarry2023-10-281-51/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | Use the argument parsing framework introduced earlier to unify the parsing of (almost) all command options. Remove custom parsing code and to avoid extraneous types, add fields with `opt` tags on command structs that have options and arguments. Commands that take no argument do not need anything. Since the command objects now carry data, create a new temporary instance of them before passing them to opt.ArgsToStruct when executing a command. A few of the commands use specific semantics for parsing (:choose), or are delegating argument parsing to another function (:sort, :search, :filter). For these commands, simply add a dummy "-" passthrough argument. Since all commands still have the argument list (after split) nothing needs to be changed in this area. There should be no functional change besides the Usage strings and reported errors which are now generated automatically. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Tested-by: Inwit <inwit@sindominio.net>
* app: export global functionsRobin Jarry2023-10-101-11/+11
| | | | | | | | | | | | | | | The single Aerc object is passed around in almost all command functions. This hinders readability. Store the single Aerc instance as a global variable. Export public functions from the app package to access methods of that object. Remove all explicit references to *app.Aerc and replace them with calls to these functions. For references to private/unexported fields and functions from within the app package, directly access the global aerc object. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* widgets: rename package to appRobin Jarry2023-10-101-8/+8
| | | | | | | | | This is the central point of all aerc. Having it named widgets is confusing. Rename it to app. It will make a cleaner transition when making the app.Aerc object available globally in the next commit. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* lint: add missing panic handlers in goroutinesRobin Jarry2023-01-061-0/+1
| | | | | | | | These issues were all reported by the new custom analyzer introduced in previous commit. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* logging: rename package to logRobin Jarry2022-12-021-5/+5
| | | | | | | | | | Use the same name than the builtin "log" package. That way, we do not risk logging in the wrong place. Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* lib: implement an eml message viewKoni Marti2022-11-091-1/+15
| | | | | | | | | Implement a MessageView representation for eml data that are not stored in a message store. With this, we can display any rfc822 message data in the message viewer. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* pipe: reorder patches based on email subjectsRobin Jarry2022-10-251-25/+7
| | | | | | | | | | | | | | | | | | | | | The Message-Id header cannot be relied upon as users can tweak it before sending. The subject seems a more reliable basis to reorder patches. Change the logic of sorting. Previously, all messages were required to look like patches to be sorted. Now if at least one message looks like a patch, all messages will be sorted by Subject before piping them. Since `git am` ignores non-patch messages, it should allow piping series of emails including reviews and comments without getting confusing errors. I have tested that this works on multiple series that appeared out of order in my INBOX with the following command (after marking the messages): :pipe -m sed -n 's/^Subject: //p' Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* logging: substitute %w for %vKoni Marti2022-10-021-1/+1
| | | | | | | | | | | | | | | | Subsitute the format specifier %w for %v in the logging facility. The logging functions use a fmt.Sprintf call behind the scene which does not recognize %w. %w should be used in fmt.Errorf when you want to wrap errors. Hence, the log entries that use %w are improperly formatted like this: ERROR 2022/10/02 09:13:57.724529 worker.go:439: could not get message info %!w(*fmt.wrapError=&{could not get structure: [snip] }) ^ Links: https://go.dev/blog/go1.13-errors Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* store: extract marking behavior and add testsKoni Marti2022-08-221-1/+1
| | | | | | | | Separate the marking functions from the message store and extract the marking behavior into its own class with tests. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: ensure errors are at least logged (errcheck)Moritz Poldrack2022-08-041-3/+10
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* lint: formatted codeMoritz Poldrack2022-08-041-1/+3
| | | | | Signed-off-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* pipe: fix ordering by message id for long patch seriesRobin Jarry2022-08-011-9/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | Git send-email Message-Id headers have the following format: DATETIME.PID-NUM-COMMITTER Unfortunately, when there are more than 9 patches, the patch number (NUM) is not zero-padded which makes ascii sorting invalid, e.g.: 1 10 11 12 2 3 4 5 6 7 8 9 Instead of: 1 2 3 4 5 6 7 8 9 10 11 12 We need the patches to be ordered correctly to pipe them to git am. Make sure to pad the patch number with zero characters to allow series of up to 999 patches. Only re-order messages before piping them if all the Message-Id headers look like git-send-email headers. Link: https://github.com/git/git/blob/v2.36.0/git-send-email.perl#L1197 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com>
* tabs: rename SelectedTab to SelectedTabContentRobin Jarry2022-07-231-1/+1
| | | | | | | | | This function returns an ui.Drawable. Use a more explicit name. This prepares for adding a new SelectedTab function which will return an ui.Tab. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* pipe: use go-mbox for writing multiple messagesKoni Marti2022-07-141-38/+13
| | | | | | | Use go-mbox for piping out multiple messages in the mbox format. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* pgp: fix pipe|open|save command behaviorTim Culverhouse2022-06-241-2/+5
| | | | | | | | | | | | | | Signed and/or encrypted PGP messages did not behave properly for pipe, open, and save commands. Specifically, the proper Message Part would not be passed to the command in the MessageViewer. This is due to the encapsulation of the body structure. This patch fixes the behavior for piping|opening|saving of message parts. Fixes: https://todo.sr.ht/~rjarry/aerc/47 Reported-by: ~ph14nix Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* visual-mode: deselect messages after performing commandTim Culverhouse2022-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | In order to better align to vim functionality: deselect visual mode selections after performing a command on the selection. This patch also introduces a new command to allow for re-selecting (remarking) the previous selection set so that commands can be chained together. The deselection only applies to msg commands that *do not* move the message from the store (those types of commands already deselect): - read/unread - flag/unflag - modify-labels - copy - pipe Previous usage to mark several messages as read and deselect all: Vjjj:read<Enter>:unmark -a<Enter> New usage, similar to vim: Vjjj:read<Enter> To chain a command together: Vjjj:read<Enter>:remark<Enter>{next command}<Enter> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* logging: added a log on panicMoritz Poldrack2022-03-231-0/+5
| | | | | | | | | | | | | Since panics still regularly "destroy" the terminal, it is hard to get a stack trace for panics you do not anticipate. This commit adds a panic handler that automatically creates a logfile inside the current working directory. It has to be added to every goroutine that is started and will repair the terminal on a panic. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* pipe: allow piping multiple marked messagesRobin Jarry2022-02-251-9/+102
| | | | | | | | | | | | | | | | When messages are marked, pipe their contents into the specified command. The messages are ordered according to their respective Message-Id headers. This allows applying complete patch series with a single command. When piping more than one message, make sure to write them in the mbox format as git am expects them to be. Link: https://en.wikipedia.org/wiki/Mbox Link: https://github.com/git/git/blob/v2.35.1/builtin/mailsplit.c#L15-L44 Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com> Tested-by: akspecs <akspecs@gmail.com>
* go.mod: change base git urlRobin Jarry2021-11-051-3/+3
| | | | | | | I'm not sure what are the implications but it seems required. Link: https://github.com/golang/go/issues/20883 Signed-off-by: Robin Jarry <robin@jarry.cc>
* Get rid of the aerc.PushError(" " + $string) idiomReto Brunner2021-01-301-2/+2
| | | | The individual callers should not be responsible for padding
* Implement style configuration.Kalyan Sriram2020-08-061-7/+7
| | | | | | Introduce the ability to configure stylesets, allowing customization of aerc's look (color scheme, font weight, etc). Default styleset is installed to /path/to/aerc/stylesets/default.
* Revert "Implement style configuration."Reto Brunner2020-07-301-7/+7
| | | | This reverts commit 1ff687ca2b0821c2cacc1fa725abb3302d2af9da.
* Implement style configuration.Kalyan Sriram2020-07-301-7/+7
| | | | | | Introduce the ability to configure stylesets, allowing customization of aerc's look (color scheme, font weight, etc). Default styleset is installed to /path/to/aerc/stylesets/default.
* pipe: don't crash if part is nilReto Brunner2020-07-051-0/+3
|
* Revert "Add Style configuration"Drew DeVault2020-05-281-9/+9
| | | | This reverts commit 0f78f06610c0e8887aba2ae50e99b86477a384b3.
* Revert "Remove duration from the status methods"Drew DeVault2020-05-281-4/+5
| | | | This reverts commit f06d683688e3d2139b14f67b7e349089e7200bf4.
* Remove duration from the status methodsReto Brunner2020-05-271-5/+4
| | | | We always set 10 seconds anyhow, might as well do that without repeating ourselfs.
* Add Style configurationReto Brunner2020-05-271-9/+9
| | | | | | | | | | The following functionalities are added to configure aerc ui styles. - Read stylesets from file with very basic fnmatch wildcard matching - Add default styleset - Support different stylesets as part of UiConfig allowing contextual styles. - Move widgets/ui elements to use the stylesets. - Add configuration manual for the styleset
* FetchBodyPart doesn't need the parent body structureReto Brunner2020-05-171-1/+1
|
* store.FetchFull: Change callback type to expose entire messageBen Fiedler2020-05-011-3/+4
| | | | | This is a prerequisite for allowing the FetchFull message to return both the message content and the message headers.
* gofmt fixesDrew DeVault2020-04-241-1/+1
|
* Use aerc.PushError where appropriateBen Fiedler2020-04-231-2/+1
| | | | Forgot an unused import, to save you the hassle here is v2.
* Refactoring: remove store from PartInfoDrew DeVault2020-03-091-1/+2
|
* FetchBodyParts: decode source in the workersReto Brunner2020-01-051-11/+1
| | | | | | | Previously the workers returned a mixture of decoded / encoded parts. This lead to a whole bunch of issues. This commit changes the msgviewer and the commands to assume parts to already be decoded
* all: purge redundant underscoresWagner Riffel2019-09-041-3/+3
| | | | Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
* commands: Don't crash when store is nilKevin Kuehler2019-07-151-0/+3
| | | | | | | On a slow network connection, running these commands without this guard will cause aerc to panic. Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
* Fix crashes when operating on empty folder (#216)Daniel Bridges2019-07-101-1/+4
|
* Fix :pipe -b actually writing to stdinDrew DeVault2019-07-081-1/+9
|
* Fix re-opening of expired pipe tabsDrew DeVault2019-07-081-2/+6
|
* :exec, :pipe: show exit status on completionDrew DeVault2019-07-081-1/+2
|
* Add :exec and :pipe -b(ackground)Drew DeVault2019-07-081-17/+44
|