Bug 441692

Summary: External tools: save output to file
Product: [Applications] kate Reporter: Christopher Yeleighton <giecrilj>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED WAITINGFORINFO    
Severity: wishlist CC: christoph
Priority: NOR    
Version First Reported In: 21.08.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Christopher Yeleighton 2021-08-29 10:49:34 UTC
SUMMARY
Please add a possibility to save output of an external tool to a file.

STEPS TO REPRODUCE
1. Define an external tool "Zip" as follows:
Name=Zip
Executable=gzip
Input=%{Document:Text}
Working directory=/tmp
Output=Save to File
Output path=%{Document:FileName}.gz

OBSERVED RESULT
Huh? Output=Save to File??

EXPECTED RESULT
An external tool "Zip"


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: openSUSE Tumbleweed 20210826
(available in About System)
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Christopher Yeleighton 2021-08-29 11:48:43 UTC
WORKAROUND (ugly)
Executable=sh
Arguments=-c 'exec "$0" >"$1"' gzip '/tmp/%{Document:FileName}.gz'
Comment 2 Dominik Haumann 2021-08-30 11:33:04 UTC
From what I understand it's that we'd need to add another line edit for the Output Path.

Of course that can be done, but isn't it that you can do that already via the arguments? You suggested already a way, maybe it can be simplified, e.g. you could write a script that your just call aa external tool.

I'm not convinced yet that adding the Output Path makes sense so far.
Comment 3 Dominik Haumann 2021-08-30 11:37:27 UTC
For instance (pseudo code):

Executable=gzip
Save=Current File
Arguments=%{Document:FilePath} %{Document:FilePath}.gz

(Not sure the order is correct).

This way, the saved file is gzipped.
Comment 4 Christopher Yeleighton 2021-08-30 11:40:44 UTC
(In reply to Dominik Haumann from comment #3)
> For instance (pseudo code):
> 
> Executable=gzip
> Save=Current File
> Arguments=%{Document:FilePath} %{Document:FilePath}.gz
> 
> (Not sure the order is correct).
> 
> This way, the saved file is gzipped.

1. I want to zip the content of the buffer.  Not every buffer can be saved.
2. gzip zips all files given as arguments.  You have just specified two files to be zipped.
Comment 5 Christopher Yeleighton 2021-08-30 11:47:33 UTC
(In reply to Dominik Haumann from comment #2)
> From what I understand it's that we'd need to add another line edit for the
> Output Path.
> 
> Of course that can be done, but isn't it that you can do that already via
> the arguments? You suggested already a way, maybe it can be simplified, e.g.
> you could write a script that your just call an external tool.

Some external tools, like gcc, allow giving the output file as an argument, some, like gzip, do not.  Calling an interpreter just to redirect the standard output seems like an overkill for a standard redirection that should be done by the plug-in.  It also makes the definition of the tool harder to understand.  If the tool produces text output that is not excessive, it can be inserted into a new buffer and let the user decide what to do if it.  If the output is binary, this method does not work: it must be saved to an actual file.

Note that a tool cannot take input from a file either.  But I have no use case for taking input from a file.
Comment 6 Christoph Cullmann 2023-08-05 19:08:58 UTC
Hi, if you still want that, you need to provide a patch.
Nobody is actively working on that plugin beside real bugfixes.

https://kate-editor.org/post/2020/2020-07-18-contributing-via-gitlab-merge-requests/