// Generated by Lisette bindgen
// Source: os/exec (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.12
import "go:context"
import "go:io"
import "go:os"
import "go:syscall"
import "go:time"
pub fn Command(name: string, arg: VarArgs<string>) -> Ref<Cmd>
pub fn CommandContext(ctx: context.Context, name: string, arg: VarArgs<string>) -> Ref<Cmd>
/// LookPath searches for an executable named file in the
/// directories named by the PATH environment variable.
/// If file contains a slash, it is tried directly and the PATH is not consulted.
/// Otherwise, on success, the result is an absolute path.
///
/// In older versions of Go, LookPath could return a path relative to the current directory.
/// As of Go 1.19, LookPath will instead return that path along with an error satisfying
/// [errors.Is](err, [ErrDot]). See the package documentation for more details.
pub fn LookPath(file: string) -> Result<string, error>
/// Cmd represents an external command being prepared or run.
///
/// A Cmd cannot be reused after calling its [Cmd.Run], [Cmd.Output] or [Cmd.CombinedOutput]
/// methods.
pub struct Cmd {
pub Path: string,
pub Args: Slice<string>,
pub Env: Slice<string>,
pub Dir: string,
pub Stdin: Option<io.Reader>,
pub Stdout: Option<io.Writer>,
pub Stderr: Option<io.Writer>,
pub ExtraFiles: Slice<Option<Ref<os.File>>>,
pub SysProcAttr: Option<Ref<syscall.SysProcAttr>>,
pub Process: Option<Ref<os.Process>>,
pub ProcessState: Option<Ref<os.ProcessState>>,
pub Err: error,
pub Cancel: fn() -> Result<(), error>,
pub WaitDelay: time.Duration,
}
/// Error is returned by [LookPath] when it fails to classify a file as an
/// executable.
pub struct Error {
pub Name: string,
pub Err: error,
}
/// An ExitError reports an unsuccessful exit by a command.
pub struct ExitError {
pub ProcessState: Option<Ref<os.ProcessState>>,
pub Stderr: Slice<uint8>,
}
/// ErrDot indicates that a path lookup resolved to an executable
/// in the current directory due to ‘.’ being in the path, either
/// implicitly or explicitly. See the package documentation for details.
///
/// Note that functions in this package do not return ErrDot directly.
/// Code should use errors.Is(err, ErrDot), not err == ErrDot,
/// to test whether a returned error err is due to this condition.
pub var ErrDot: error
/// ErrNotFound is the error resulting if a path search failed to find an executable file.
pub var ErrNotFound: error
/// ErrWaitDelay is returned by [Cmd.Wait] if the process exits with a
/// successful status code but its output pipes are not closed before the
/// command's WaitDelay expires.
pub var ErrWaitDelay: error
impl Cmd {
/// CombinedOutput runs the command and returns its combined standard
/// output and standard error.
fn CombinedOutput(self: Ref<Cmd>) -> Result<Slice<uint8>, error>
/// Environ returns a copy of the environment in which the command would be run
/// as it is currently configured.
fn Environ(self: Ref<Cmd>) -> Slice<string>
/// Output runs the command and returns its standard output.
/// Any returned error will usually be of type [*ExitError].
/// If c.Stderr was nil and the returned error is of type
/// [*ExitError], Output populates the Stderr field of the
/// returned error.
fn Output(self: Ref<Cmd>) -> Result<Slice<uint8>, error>
/// Run starts the specified command and waits for it to complete.
///
/// The returned error is nil if the command runs, has no problems
/// copying stdin, stdout, and stderr, and exits with a zero exit
/// status.
///
/// If the command starts but does not complete successfully, the error is of
/// type [*ExitError]. Other error types may be returned for other situations.
///
/// If the calling goroutine has locked the operating system thread
/// with [runtime.LockOSThread] and modified any inheritable OS-level
/// thread state (for example, Linux or Plan 9 name spaces), the new
/// process will inherit the caller's thread state.
fn Run(self: Ref<Cmd>) -> Result<(), error>
/// Start starts the specified command but does not wait for it to complete.
///
/// If Start returns successfully, the c.Process field will be set.
///
/// After a successful call to Start the [Cmd.Wait] method must be called in
/// order to release associated system resources.
fn Start(self: Ref<Cmd>) -> Result<(), error>
/// StderrPipe returns a pipe that will be connected to the command's
/// standard error when the command starts.
///
/// [Cmd.Wait] will close the pipe after seeing the command exit, so most callers
/// need not close the pipe themselves. It is thus incorrect to call Wait
/// before all reads from the pipe have completed.
/// For the same reason, it is incorrect to use [Cmd.Run] when using StderrPipe.
/// See the StdoutPipe example for idiomatic usage.
fn StderrPipe(self: Ref<Cmd>) -> Result<io.ReadCloser, error>
/// StdinPipe returns a pipe that will be connected to the command's
/// standard input when the command starts.
/// The pipe will be closed automatically after [Cmd.Wait] sees the command exit.
/// A caller need only call Close to force the pipe to close sooner.
/// For example, if the command being run will not exit until standard input
/// is closed, the caller must close the pipe.
fn StdinPipe(self: Ref<Cmd>) -> Result<io.WriteCloser, error>
/// StdoutPipe returns a pipe that will be connected to the command's
/// standard output when the command starts.
///
/// [Cmd.Wait] will close the pipe after seeing the command exit, so most callers
/// need not close the pipe themselves. It is thus incorrect to call Wait
/// before all reads from the pipe have completed.
/// For the same reason, it is incorrect to call [Cmd.Run] when using StdoutPipe.
/// See the example for idiomatic usage.
fn StdoutPipe(self: Ref<Cmd>) -> Result<io.ReadCloser, error>
/// String returns a human-readable description of c.
/// It is intended only for debugging.
/// In particular, it is not suitable for use as input to a shell.
/// The output of String may vary across Go releases.
fn String(self: Ref<Cmd>) -> string
/// Wait waits for the command to exit and waits for any copying to
/// stdin or copying from stdout or stderr to complete.
///
/// The command must have been started by [Cmd.Start].
///
/// The returned error is nil if the command runs, has no problems
/// copying stdin, stdout, and stderr, and exits with a zero exit
/// status.
///
/// If the command fails to run or doesn't complete successfully, the
/// error is of type [*ExitError]. Other error types may be
/// returned for I/O problems.
///
/// If any of c.Stdin, c.Stdout or c.Stderr are not an [*os.File], Wait also waits
/// for the respective I/O loop copying to or from the process to complete.
///
/// Wait releases any resources associated with the [Cmd].
fn Wait(self: Ref<Cmd>) -> Result<(), error>
}
impl Error {
fn Error(self: Ref<Error>) -> string
fn Unwrap(self: Ref<Error>) -> Option<error>
}
impl ExitError {
fn Error(self: Ref<ExitError>) -> string
/// ExitCode returns the exit code of the exited process, or -1
/// if the process hasn't exited or was terminated by a signal.
fn ExitCode(self) -> int
/// Exited reports whether the program has exited.
/// On Unix systems this reports true if the program exited due to calling exit,
/// but false if the program terminated due to a signal.
fn Exited(self) -> bool
/// Pid returns the process id of the exited process.
fn Pid(self) -> int
fn String(self) -> string
/// Success reports whether the program exited successfully,
/// such as with exit status 0 on Unix.
fn Success(self) -> bool
/// Sys returns system-dependent exit information about
/// the process. Convert it to the appropriate underlying
/// type, such as [syscall.WaitStatus] on Unix, to access its contents.
fn Sys(self) -> Unknown
/// SysUsage returns system-dependent resource usage information about
/// the exited process. Convert it to the appropriate underlying
/// type, such as [*syscall.Rusage] on Unix, to access its contents.
/// (On Unix, *syscall.Rusage matches struct rusage as defined in the
/// getrusage(2) manual page.)
fn SysUsage(self) -> Unknown
/// SystemTime returns the system CPU time of the exited process and its children.
fn SystemTime(self) -> time.Duration
/// UserTime returns the user CPU time of the exited process and its children.
fn UserTime(self) -> time.Duration
}