diff options
| author | Tommaso Negri <me@tommasongr.com> | 2026-08-09 15:33:16 +0200 |
|---|---|---|
| committer | Tommaso Negri <me@tommasongr.com> | 2026-08-09 15:33:16 +0200 |
| commit | d7bc6c009bb728aff82032162095228ce12e2495 (patch) | |
| tree | d3b285cc6b0784d60deb419a7f54bb8209a26108 /Sources/phbar/Models/Block.swift | |
| parent | 1f915152b061e9c5d655e3e87f068e29cb4ff1a0 (diff) | |
| download | bar-d7bc6c009bb728aff82032162095228ce12e2495.tar.gz bar-d7bc6c009bb728aff82032162095228ce12e2495.zip | |
pass block name to the command environment
Diffstat (limited to 'Sources/phbar/Models/Block.swift')
| -rw-r--r-- | Sources/phbar/Models/Block.swift | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Sources/phbar/Models/Block.swift b/Sources/phbar/Models/Block.swift index 95c4ada..fe575e4 100644 --- a/Sources/phbar/Models/Block.swift +++ b/Sources/phbar/Models/Block.swift @@ -58,10 +58,14 @@ final class Block: ObservableObject, Identifiable { } /// Re-run the command and update the cells on the main actor. - func runScript() { + func runScript(env: [String: String] = [:]) { let command = self.command + + var env = env + env.updateValue(name, forKey: "BLOCK") + Task.detached(priority: .utility) { [weak self] in - let lines = Runner.run(command) + let lines = Runner.run(command, env: env) await self?.apply(lines) } } |
