#os/exec
Xu 0.16.0 API
import: #os/exec
counts: 3 functions, 11 methods, 1 types, 0 constants, 0 method sets
Process execution with argument arrays, run/output/combined_output, start/wait, and stdin/stdout pipes.
struct Cmd
pub struct Cmd {
pub path string
pub args []string
pub dir string
pub ctx context.Context
pub has_ctx int
}
Purpose
Structure encapsulating path, args, dir, ctx, has_ctx.
Public fields
path string- filesystem path
args []string- variadic arguments
dir string- directory
ctx context.Context- field (context.Context)
has_ctx int- field (int)
($&Cmd) set_dir
pub fn (c $&Cmd) set_dir(dir string)
Purpose
Operation on $&Cmd: set dir.
Parameters
c $&Cmd- The
Cmd instance used by this call (exclusive borrow).
dir string- directory (string)
Returns
This call does not return a value.
command
pub fn command(name string, args <-> string) Cmd
Purpose
Execute command.
Parameters
name string- name (string)
args <-> string- variadic string (seen inside the function as []string)
Returns
Cmd — a value of this type
command_context
pub fn command_context(ctx context.Context, name string, args <-> string) Cmd
Purpose
Command context.
Parameters
ctx context.Context- ctx (context.Context)
name string- name (string)
args <-> string- variadic string (seen inside the function as []string)
Returns
Cmd — a value of this type
look_path
pub fn look_path(file string) string
Purpose
Look path. Throws on failure; handle the error or propagate it to the caller.
Parameters
file string- file (string)
Returns
string — result string
(&Cmd) run_status
pub fn (c &Cmd) run_status() int
Purpose
run_status returns the child status while still throwing on launch, cancellation, and wait errors. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Cmd- The
Cmd instance used by this call (borrow).
Returns
int — a value of this type
(&Cmd) run
pub fn (c &Cmd) run() int
Purpose
Execute run on &Cmd. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Cmd- The
Cmd instance used by this call (borrow).
Returns
int — a value of this type
(&Cmd) output
pub fn (c &Cmd) output() string
Purpose
Execute output on &Cmd. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Cmd- The
Cmd instance used by this call (borrow).
Returns
string — result string
($&Cmd) close_unstarted_pipes
pub fn (c $&Cmd) close_unstarted_pipes()
Purpose
Release pipe endpoints when setup fails before start. Once started, the runtime owns the child endpoints; closing those stale fd numbers is unsafe.
Parameters
c $&Cmd- The
Cmd instance used by this call (exclusive borrow).
Returns
This call does not return a value.
($&Cmd) stdout_pipe
pub fn (c $&Cmd) stdout_pipe() os.File
Purpose
Operation on $&Cmd: stdout pipe. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&Cmd- The
Cmd instance used by this call (exclusive borrow).
Returns
os.File — a value of this type
($&Cmd) stderr_pipe
pub fn (c $&Cmd) stderr_pipe() os.File
Purpose
Operation on $&Cmd: stderr pipe. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&Cmd- The
Cmd instance used by this call (exclusive borrow).
Returns
os.File — a value of this type
($&Cmd) stdin_pipe
pub fn (c $&Cmd) stdin_pipe() os.File
Purpose
Operation on $&Cmd: stdin pipe. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&Cmd- The
Cmd instance used by this call (exclusive borrow).
Returns
os.File — a value of this type
($&Cmd) start
pub fn (c $&Cmd) start() int
Purpose
Execute start on $&Cmd. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&Cmd- The
Cmd instance used by this call (exclusive borrow).
Returns
int — a value of this type
($&Cmd) wait
pub fn (c $&Cmd) wait() int
Purpose
Execute wait on $&Cmd. Throws on failure; handle the error or propagate it to the caller.
Parameters
c $&Cmd- The
Cmd instance used by this call (exclusive borrow).
Returns
int — a value of this type
(&Cmd) combined_output
pub fn (c &Cmd) combined_output() string
Purpose
Operation on &Cmd: combined output. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Cmd- The
Cmd instance used by this call (borrow).
Returns
string — result string