@zturnlibs/ztron-api


shell

Classes

Command

Defined in: shell.ts:70

A command builder mirroring Tauri's Command class. Streams stdout/stderr via the ztron://shell-output / ztron://shell-error events.

Constructors

Constructor

new Command(program, args?, options?): Command

Defined in: shell.ts:76

Parameters
program

string

args?

string[] = []

options?

CommandOptions = {}

Returns

Command

Properties

args

readonly args: string[]

Defined in: shell.ts:72

options

readonly options: CommandOptions

Defined in: shell.ts:73

program

readonly program: string

Defined in: shell.ts:71

Methods

execute()

execute(): Promise<ExecResult>

Defined in: shell.ts:163

Runs the command, collecting full output, and resolves with it.

Returns

Promise<ExecResult>

kill()

kill(cid, signal?): Promise<void>

Defined in: shell.ts:158

Kills a spawned command (SIGTERM by default).

Parameters
cid

string

signal?

number = 15

Returns

Promise<void>

on()

on(event, handler): this

Defined in: shell.ts:87

Registers an event listener; returns this for chaining.

Parameters
event

CommandEvent

handler

(data) => void

Returns

this

spawn()

spawn(): Promise<void>

Defined in: shell.ts:99

Spawns the command, streaming output events; resolves on exit.

Returns

Promise<void>

spawnInteractive()

spawnInteractive(): Promise<string>

Defined in: shell.ts:126

Long-lived spawn: resolves with a command id once started; output keeps streaming through on("stdout"/"stderr"), termination through on("terminated") ({cid, code}). Use write and kill to drive interactive processes.

Returns

Promise<string>

status()

status(): Promise<number>

Defined in: shell.ts:197

Runs the command and resolves with its exit code.

Returns

Promise<number>

write()

write(cid, data): Promise<void>

Defined in: shell.ts:153

Writes to a spawned command's stdin (spawnInteractive cid).

Parameters
cid

string

data

string

Returns

Promise<void>

sidecar()

static sidecar(): never

Defined in: shell.ts:202

Not supported (Ztron has no sidecar bundling).

Returns

never

Interfaces

CommandOptions

Defined in: shell.ts:59

Properties

cwd?

optional cwd?: string

Defined in: shell.ts:60

env?

optional env?: Record<string, string>

Defined in: shell.ts:61


ExecResult

Defined in: shell.ts:5

Properties

code

code: number

Defined in: shell.ts:6

stderr

stderr: string

Defined in: shell.ts:8

stdout

stdout: string

Defined in: shell.ts:7

Variables

shell

const shell: object

Defined in: shell.ts:207

Type Declaration

Command

Command: typeof Command

execute

execute: (program, args, options) => Promise<ExecResult>

Parameters
program

string

args?

string[] = []

options?
cwd?

string

env?

Record<string, string>

Returns

Promise<ExecResult>

executeStream

executeStream: (program, args, options) => Promise<{ code: number; }>

Executes a command and streams stdout chunks to onChunk as they arrive (long-running commands). Resolves with the exit code.

Parameters
program

string

args?

string[] = []

options?

object & object = {}

Returns

Promise<{ code: number; }>

open

open: (url) => Promise<{ opened: boolean; }>

Opens an http(s) URL in the default browser (fire-and-forget).

Parameters
url

string

Returns

Promise<{ opened: boolean; }>

Functions

execute()

execute(program, args?, options?): Promise<ExecResult>

Defined in: shell.ts:11

Parameters

program

string

args?

string[] = []

options?
cwd?

string

env?

Record<string, string>

Returns

Promise<ExecResult>


executeStream()

executeStream(program, args?, options?): Promise<{ code: number; }>

Defined in: shell.ts:27

Executes a command and streams stdout chunks to onChunk as they arrive (long-running commands). Resolves with the exit code.

Parameters

program

string

args?

string[] = []

options?

object & object = {}

Returns

Promise<{ code: number; }>


open()

open(url): Promise<{ opened: boolean; }>

Defined in: shell.ts:55

Opens an http(s) URL in the default browser (fire-and-forget).

Parameters

url

string

Returns

Promise<{ opened: boolean; }>