Skip to main content

Module util

Module util 

Source
Expand description

Small helpers shared by the zx-compatible API: quoting, duration parsing, command assembly and name normalisation.

Re-exports§

pub use crate::local_bin::path_key;
pub use crate::local_bin::prefer_local_bin;
pub use crate::local_bin::PATH_DELIMITER;

Enums§

ZxArg
A value interpolated into a command template.

Traits§

IntoZxArg
Conversion of Rust values into command template arguments.

Functions§

build_cmd
Interleave template pieces with quoted args.
duration_from_millis
Convert milliseconds into a Duration, rejecting negative and NaN values.
is_safe_word
Returns true when arg only consists of characters that never need quoting in a POSIX shell (letters, digits and _/.-+@:=,%).
parse_bool
Parse "true" / "false"; any other value yields None.
parse_duration
Parse a zx duration string: "100" (ms), "500ms", "2s" or "2m".
quote
Quote a value for bash the way zx does.
quote_powershell
Quote a value for PowerShell the way zx does: empty -> '', safe words unchanged, otherwise single-quoted with embedded quotes doubled.
random_id
Random lower-case alphanumeric identifier (used for temp names and ids).
split_template
Split a zx! format string on {} placeholders ({{}} is a literal {}).
to_camel_case
Convert SOME_NAME / kebab-name into someName / kebabName.
zx_arg
Convert any supported value into a ZxArg.

Type Aliases§

QuoteFn
Signature of the quoting function used to interpolate arguments.