zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
24.96k stars 1.17k forks source link

Is it possible to save file to stdin of another program? #3083

Closed dustdfg closed 9 months ago

dustdfg commented 10 months ago

In my plugin I need to use a program, something like cli command for accessing files stored in for example database. Its "api" looks like: app print file_id that prints file to stdout and app save file_id that reads file from stdin and saves to db. Micro allows to run command and get result from it, thanks to RunCommand. IIUC It means that I can use app print file_id for getting file from the db but I don't see how I can use app save file_id because I can't write current buffer to pipe of another program...

dustdfg commented 9 months ago

Ok I actually found the solution but it is Unix only (who needs windows but still). I used named pipes thought nature of pipes differs from nature of files so if accidentally do something wrong it can "crash" micro because it will infinitely wait while the underlying program will read from named pipe...