gdDocumentation0.8.0

API reference

GDCLIFlags

Parser reading typed bool flags such as true/false and 1/0, integers with 0x, 0o, and 0b prefixes, and collecting positional arguments.

Methods

set_name

set_name(name: String) -> void

---------------- Command-line flags ----------------

Parameters

NameTypeDefaultDescription
nameStringRequiredName used to register or look up the corresponding entry.

Return value

void

No value is returned.

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

flag_bool

flag_bool(name: String, fallback: bool, help: String = "") -> void

Declare a boolean command-line flag.

Parameters

NameTypeDefaultDescription
nameStringRequiredName used to register or look up the corresponding entry.
fallbackboolRequiredValue returned when the requested value is unavailable or omitted.
helpString""User-facing description shown in command-line usage output.

Return value

void

No value is returned.

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

flag_str

flag_str(name: String, fallback: String, help: String = "") -> void

Declare a string command-line flag.

Parameters

NameTypeDefaultDescription
nameStringRequiredName used to register or look up the corresponding entry.
fallbackStringRequiredValue returned when the requested value is unavailable or omitted.
helpString""User-facing description shown in command-line usage output.

Return value

void

No value is returned.

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

flag_int

flag_int(name: String, fallback: int, help: String = "") -> void

Declare an integer command-line flag.

Parameters

NameTypeDefaultDescription
nameStringRequiredName used to register or look up the corresponding entry.
fallbackintRequiredValue returned when the requested value is unavailable or omitted.
helpString""User-facing description shown in command-line usage output.

Return value

void

No value is returned.

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

parse

parse(args: Array) -> Variant, Err

Accept both --name=value and --name value.

Parameters

NameTypeDefaultDescription
argsArrayRequiredArguments in call or parameter-binding order.

Return value

Variant, 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.

get_bool

get_bool(name: String) -> bool

Return a boolean flag's current value.

Parameters

NameTypeDefaultDescription
nameStringRequiredName used to register or look up the corresponding entry.

Return value

bool

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

get_str

get_str(name: String) -> String

Return a string flag's current value.

Parameters

NameTypeDefaultDescription
nameStringRequiredName used to register or look up the corresponding entry.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

get_int

get_int(name: String) -> int

Return an integer flag's current value.

Parameters

NameTypeDefaultDescription
nameStringRequiredName used to register or look up the corresponding entry.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

get_rest

get_rest() -> PackedStringArray

Return positional arguments left after parsing registered flags.

Parameters

No parameters.

Return value

PackedStringArray

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

usage

usage() -> String

Return usage guidance.

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.