gdDocumentation0.8.0

API reference

GD.cli

Entry for gd's version and docs, flags, and allowed environment and system information.

Methods

version

version() -> String

Return 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() -> String

Return 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() -> GDCLIFlags

Create 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) -> Variant

Return a permitted environment value or its default.

Parameters

NameTypeDefaultDescription
nameStringRequiredName used to register or look up the corresponding entry.
fallbackVariantnullValue 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, Err

Return a required environment value or Err.

Parameters

NameTypeDefaultDescription
nameStringRequiredName 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() -> String

Return 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() -> String

Return 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() -> String

Return 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() -> bool

Check 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() -> bool

Check 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() -> bool

Check 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) -> String

Decorate terminal text using an ANSI code.

Parameters

NameTypeDefaultDescription
textStringRequiredText to inspect, decode or transform; the input is not modified in place.
codeintRequiredTerminal 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) -> String

Decorate terminal text in red.

Parameters

NameTypeDefaultDescription
textStringRequiredText 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) -> String

Decorate terminal text in green.

Parameters

NameTypeDefaultDescription
textStringRequiredText 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) -> String

Decorate terminal text in yellow.

Parameters

NameTypeDefaultDescription
textStringRequiredText 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) -> String

Decorate terminal text in blue.

Parameters

NameTypeDefaultDescription
textStringRequiredText 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) -> String

Decorate terminal text in gray.

Parameters

NameTypeDefaultDescription
textStringRequiredText 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) -> String

Decorate terminal text in bold.

Parameters

NameTypeDefaultDescription
textStringRequiredText 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, Err

Start 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

NameTypeDefaultDescription
pathStringRequiredFilesystem path; relative paths use the execution directory and access follows configured permissions.
argsPackedStringArray[]Arguments in call or parameter-binding order.
optsDictionary{ }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, Err

Start a child process and return an awaitable completion signal.

Parameters

NameTypeDefaultDescription
pathStringRequiredFilesystem path; relative paths use the execution directory and access follows configured permissions.
argsPackedStringArray[]Arguments in call or parameter-binding order.
optsDictionary{ }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.