Taitava / obsidian-shellcommands

Execute system commands via hotkeys or command palette in Obsidian (https://obsidian.md). Some automated events are also supported, and execution via URI links.
GNU General Public License v3.0
348 stars 11 forks source link

Real time output handling #275

Closed Taitava closed 1 year ago

Taitava commented 1 year ago

Discussed in https://github.com/Taitava/obsidian-shellcommands/discussions/64

So far, output has been handled after the whole shell command execution process has finished. That's perfectly fine for most shell commands, if they run quickly.

I will add a choice to start handling output before a shell command has finished executing. It will allow e.g. to get output text inserted to current note in multiple phases during a single shell command executon process.

The traditional way will also be still available, and it will stay as a default output handling mode.

128 gave me some implementation ideas: https://github.com/Taitava/obsidian-shellcommands/pull/128/files?diff=unified&w=0.

TODO:

Taitava commented 1 year ago

This feature is quite complete, I think. But I have one problem that I need to think about. If both stdout and stderr contain output, sometimes they will be outputted in a bit wrong order.

Example:

echo Line0
[Console]::Error.WriteLine("Error line1")
[Console]::Error.WriteLine("Error line2")
echo Line1
echo Line2
echo Line3
echo Line4
echo Line5
echo Line6
echo Line7
echo Line8
echo Line9

Sometimes Error line1 and Error line2 are processed after Line1, or even later. According to my quick research, it looks like there's no way to guarantee the output order:

I have only tested this in PowerShell.

I'll continue thinking about this.

Taitava commented 1 year ago

I have one problem that I need to think about. If both stdout and stderr contain output, sometimes they will be outputted in a bit wrong order.

...

I'll continue thinking about this.

I have decided not to search for any solutions for this problem - at least at this time. This feature can be released even with this problem existing.

Taitava commented 1 year ago

Documentation is done. Still needs tests.

Taitava commented 1 year ago

Still need to make tests for the following output channels:

Taitava commented 1 year ago

All tests are now created. The feature should be ready now, and will be released in 0.17.0.

Taitava commented 1 year ago

Released now.