Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public interface IPublicAPI
/// </summary>
void RestartApp();

/// <summary>
/// Run a shell command or external program
/// </summary>
/// <param name="cmd">The command or program to run</param>
void ShellRun(string cmd);

/// <summary>
/// Save everything, all of Flow Launcher and plugins' data and settings
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletions Flow.Launcher/PublicAPIInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ public void OpenSettingDialog()
});
}

public void ShellRun(string cmd)
{
System.Diagnostics.Process process = new();
var startInfo = process.StartInfo;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = $"/C {cmd}";
startInfo.CreateNoWindow = true;
process.Start();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spedrickson have you tested this with your plugin? the method is not returning the result from the command

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it works for my plugin, but I'm only using it to launch files (identical to Browser plugin), not receive data back on the plugin side.

One concern with returning results: right now the commands are launched in a separate process to prevent locking up the Flow UI, so even long-running commands won't impact user experience. Maintaining a list of running processes is easy enough, but then we get into design decisions like whether return order should be maintained.

Might be worth adding a separate function like GetShellRun ,that works the same way but keeps the process and regularly polls it for output?

}

public void StartLoadingBar() => _mainVM.ProgressBarVisibility = Visibility.Visible;

public void StopLoadingBar() => _mainVM.ProgressBarVisibility = Visibility.Collapsed;
Expand Down