API reference
GD.cli
Entry for gd's version and docs, flags, and allowed environment and system information.
Methods
version() -> Stringdocs_url() -> Stringflags() -> GDCLIFlagsenv(name: String, fallback: Variant = null) -> Variantrequire_env(name: String) -> String, Errcwd() -> Stringplatform() -> Stringarch() -> Stringstdin_tty() -> boolstdout_tty() -> boolstderr_tty() -> boolpaint(text: String, code: int) -> Stringred(text: String) -> Stringgreen(text: String) -> Stringyellow(text: String) -> Stringblue(text: String) -> Stringgray(text: String) -> Stringbold(text: String) -> Stringrun(path: String, args: PackedStringArray = [], opts: Dictionary = { }) -> Dictionary, Errrun_async(path: String, args: PackedStringArray = [], opts: Dictionary = { }) -> await Dictionary, Err
version
version() -> StringReturn the running executable's version.
Parameters
No parameters.
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
docs_url
docs_url() -> StringReturn the upstream documentation base used to resolve version-independent links.
Parameters
No parameters.
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
flags
flags() -> GDCLIFlagsCreate a command-line flag parser.
Parameters
No parameters.
Return value
GDCLIFlags
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
env
env(name: String, fallback: Variant = null) -> VariantReturn a permitted environment value or its default.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | String | Required | Name used to register or look up the corresponding entry. |
fallback | Variant | null | Value returned when the requested value is unavailable or omitted. |
Return value
Variant
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
require_env
require_env(name: String) -> String, ErrReturn a required environment value or Err.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name | String | Required | Name used to register or look up the corresponding entry. |
Return value
String, Err
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
cwd
cwd() -> StringReturn the current working directory.
Parameters
No parameters.
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
platform
platform() -> StringReturn the operating-system name only when permitted.
Parameters
No parameters.
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
arch
arch() -> StringReturn the CPU architecture name only when permitted.
Parameters
No parameters.
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
stdin_tty
stdin_tty() -> boolCheck whether standard input is an interactive terminal.
Parameters
No parameters.
Return value
bool
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
stdout_tty
stdout_tty() -> boolCheck whether standard output is an interactive terminal.
Parameters
No parameters.
Return value
bool
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
stderr_tty
stderr_tty() -> boolCheck whether standard error is an interactive terminal.
Parameters
No parameters.
Return value
bool
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
paint
paint(text: String, code: int) -> StringDecorate terminal text using an ANSI code.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
code | int | Required | Terminal SGR style code applied when color output is enabled. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
red
red(text: String) -> StringDecorate terminal text in red.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
green
green(text: String) -> StringDecorate terminal text in green.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
yellow
yellow(text: String) -> StringDecorate terminal text in yellow.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
blue
blue(text: String) -> StringDecorate terminal text in blue.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
gray
gray(text: String) -> StringDecorate terminal text in gray.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
bold
bold(text: String) -> StringDecorate terminal text in bold.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | Required | Text to inspect, decode or transform; the input is not modified in place. |
Return value
String
Errors
This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.
run
run(path: String, args: PackedStringArray = [], opts: Dictionary = { }) -> Dictionary, ErrStart a child process and return an awaitable completion signal.
Return exit code and captured output. A nonzero exit returns Err with info.code; timeout and cancellation also retain code and output in the value.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
path | String | Required | Filesystem path; relative paths use the execution directory and access follows configured permissions. |
args | PackedStringArray | [] | Arguments in call or parameter-binding order. |
opts | Dictionary | { } | Named options for this operation. Omitted entries use their documented defaults. |
Return value
Dictionary, Err
Suspends only the calling routine until the operation completes. No explicit await is needed.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.
run_async
run_async(path: String, args: PackedStringArray = [], opts: Dictionary = { }) -> await Dictionary, ErrStart a child process and return an awaitable completion signal.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
path | String | Required | Filesystem path; relative paths use the execution directory and access follows configured permissions. |
args | PackedStringArray | [] | Arguments in call or parameter-binding order. |
opts | Dictionary | { } | Named options for this operation. Omitted entries use their documented defaults. |
Return value
await Dictionary, Err
Returns a Signal. Use await to receive the completion value shown in the signature.
Errors
The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.