Official documentation:
- https://pkg.go.dev/cuelang.org/go/pkg/tool
cue help cmd
cue cmd test_cli
cue test_cli
cue cmd test_exec
cue test_exec
Some commands provide input and output, for example cli.Ask
has en output response
:
command: test_cli: {
ask: cli.Ask & {
prompt: "What is your name?"
response: string
}
display: cli.Print &{
text: "hello "+ask.response
}
}
The command exec.Run
has an input stdin
, an input stdout
and stderr
:
command: test_exec: {
ask: cli.Ask & {
prompt: "What is your name?"
response: string
}
echo: exec.Run & {
cmd: ["echo", "Hello", ask.response + "!"]
stdout: string // capture stdout, don't print to the terminal
}
display: cli.Print &{
text: "sdout of task echo: " + echo.stdout
}
}
More info in the documentation of tasks:
cli.Ask
: ask an input to user (Documention)cli.Print
: output a text (Documention)exec.Run
: run a bash command (Documention)file.Read
: read the content of a file (Documention)file.Append
: append a file (Documention)file.Glob
: list files (Documention)file.Mkdir
: create a directory (Documention)file.MkdirAll
: create a directory and parents (Documention)file.MkdirTemp
: create a directory (Documention)file.RemoveAll
: delete path and childs (Documention)http.Do
: do a HTTP call (GET/POST/PUT/DELETE) (Documention)os.Setenv
: create a env var (Documention)os.Getenv
: get a env var (Documention)os.Environ
: get all env var (Documention)