Help Topics for builtin


Sample CLI

gway abort

References

Signature

(message: str, *, exit_code: int = 1) -> int

Docstring

Abort with error message.





Sample CLI

gway envs

Signature

(filter: str = None) -> dict

Docstring

Return all environment variables in a dictionary.

Sample CLI

gway hello-world

References

Signature

(name: str = 'World', *, greeting: str = 'Hello', **kwargs)

Docstring

Smoke test function.


Sample CLI

gway infer-type

Signature

(value, default=None, **types)

Docstring

Try casting `value` to each provided type. If a cast succeeds, returns the corresponding key (name). If none succeed, returns default. Example: gw.infer_type("42", INTEGER=int, REAL=float) # => "INTEGER" gw.infer_type("hello", INTEGER=int, default="TEXT") # => "TEXT"


Sample CLI

gway random-id

Signature

(length: int = 8, alphabet: str = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghikmnopqrstuvwxyz23456789') -> str

Docstring

Generate a readable random ID, avoiding confusing characters. Args: length: Length of the ID (default 8) alphabet: Characters to choose from (default: unambiguous alphanumerics) Returns: A visually clear, randomly generated string.

Sample CLI

gway resource

References

Signature

(*parts, touch=False, check=False, text=False, dir=False)

Docstring

Locate or create a resource by searching in: 1. Current working directory 2. GWAY_ROOT environment variable 3. User home directory If not found, returns the path in the CWD (which may not exist) unless check=True, in which case aborts. Arguments: - touch: if True, create the file (and parents) if it does not exist. - dir: if True, create the final path as a directory, not a file. - text: if True, return file contents as text, not a Path. - check: if True, abort if resource does not exist.

TODOs

# TODO: Consider if we should also be compatible with BASE_PATH and GWAY_PATH # 2. GWAY_ROOT env

Sample CLI

gway resource-list

References

Signature

(*parts, ext=None, prefix=None, suffix=None)

Docstring

List all files in a resourced directory that match optional filters. This builds a path just like `resource`, but treats it as a directory, then lists all files inside that match the given extension, prefix, and/or suffix. Args: *parts: Path components like ("subdir",). ext (str): Optional file extension to match, e.g., ".txt". prefix (str): Optional filename prefix to match. suffix (str): Optional filename suffix to match. Returns: list[pathlib.Path]: Sorted list of matching files by creation time (oldest first).


Sample CLI

gway run-recipe

References

Signature

(*script: str, **context)

Docstring

Run commands parsed from a .gwr file, falling back to the 'recipes/' resource bundle. Recipes are gway scripts composed of one command per line with optional comments.

Sample CLI

gway sample-cli-args

Signature

(func)

Docstring

Generate a sample CLI string for a function.

Sample CLI

gway shell

Signature

()

Docstring

Launch an interactive Python shell with 'from gway import gw' preloaded.

Sample CLI

gway sigils

Signature

(*args: str)

Docstring

List the valid sigils found in any of the given args.

Sample CLI

gway test

References

Signature

(*, root: str = 'tests', filter=None, project=None)

Docstring

Execute all automatically detected test suites, logging to logs/test.log.

TODOs

# TODO: Implement a 'project' mode. Instead of performing the hard-coded GWAY test # suite, run an abstract test battery against the project or collection of projects

Sample CLI

gway to-html

Signature

(obj, **kwargs)

Docstring

Convert an arbitrary Python object to structured HTML. Args: obj: The object to convert. **kwargs: Optional keyword arguments for customization: - class_prefix: Prefix for HTML class names. - max_depth: Maximum recursion depth. - skip_none: Skip None values. - pretty: Insert newlines/indentation. Returns: A string of HTML representing the object.

Sample CLI

gway to-list

Signature

(obj, flat=False)

Docstring

Convert, and optionally flatten, any object into a list with a set of intuitive rules. - If `obj` is a string with spaces, commas, colons, or semicolons, split it. - If `obj` is a dict or a view (e.g., bottle view dict), return ["key=value", ...]. - If `obj` is a list or tuple, return it as a list. - If `obj` is an iterable, convert to list. - Otherwise, return [obj].

Sample CLI

gway unwrap-all

Signature

(obj: Any, expected: Optional[Type] = None) -> List[Any]

Docstring

Returns a list of all matching unwrapped values from obj.

Sample CLI

gway unwrap-one

Signature

(obj: Any, expected: Optional[Type] = None) -> Any

Docstring

Returns the first matching unwrapped value from obj.

Sample CLI

gway version

References

Signature

(check=None) -> str

Docstring

Return the version of the package. If `check` is provided, ensure the version meets or exceeds the required `major.minor.patch` string. Raise AssertionError if requirement is not met.