Skip to main content

Module util

Module util 

Source
Expand description

The text checks and the console helpers the gadk commands print with. The flag-usage helper lives in gadk-launcher as flag_usage (the launcher’s user).

Structs§

Printer
The step printer log_start_stop builds. The arguments of one call arrive as one list, so a line is , a green > and a reset, a space, then [, the arguments’ text joined by single spaces, and ].
ReprintableStream
Forwards a child’s output to stream, writing prefix first and in place of every newline, so each output line is indented under the step.

Constants§

BLUE
CYAN
GRAY
GREEN
MAGENTA
RED
RESET
WHITE
YELLOW

Functions§

center_string
s padded with spaces to width w, the extra space on the right; w counts bytes.
log_command
Prints Running : <dir> <cmd> (yellow Running : , the directory, a reset, a space and the command), then runs cmd with its stdout and stderr each through a ReprintableStream onto the printer’s writer (both go to the command’s stdout). A failed start is its error text; a non-zero exit is exit status <n>.
log_start_stop
Prints <msg> : Starting, runs command with a Printer, prints an empty line, then <msg> : Finished successfully or <msg> : Finished with error and Error: <err>, and returns command’s result.
new_reprintable_stream
Builds a stream over s: the prefix is "\n " + color + prefix + " > " + Reset.
strip_extension
p without its extension, which must be expected.
validate_dockerfile_safe
Rejects ", `, \, every C0 control byte and invalid UTF-8, so a value embedded in a generated Dockerfile’s exec-form CMD keeps the line a valid JSON array and reaches the container unchanged. The weaker of the two checks; a value that reaches a RUN line needs validate_shell_arg_safe.
validate_shell_arg_safe
Admits only letters, digits, ., /, -, _ and non-ASCII runes (valid UTF-8), the check for a value reaching a shell-form RUN line or a COPY operand.