set

gest config set: set a configuration value.

struct Command

source

pub struct Command

Set a configuration value.

Field Type Description
key String Dot-delimited config key (e.g. log.level).
value String Value to assign; auto-parsed as bool, int, float, or string.
global bool Write to the global (user-level) config instead of the project config.

Implements FromArgMatches, Args, Debug.

Command::call

source

pub async fn call(&self, _context: &AppContext) -> Result<(), Error>

Write value to the selected project or global config file.

Parameter Type Description
_context &AppContext the application context, which this command does not use
returns Result<(), Error> Ok(()) when the command succeeds, or the error that stopped it.

fn parse_scalar

source

fn parse_scalar(s: &str) -> Value

Parse a raw string into the most specific TOML scalar type.

Parameter Type Description
s &str the value as typed on the command line
returns Value A boolean for true or false, then an integer, then a finite float, else a string.

fn resolve_global_config_path

source

fn resolve_global_config_path() -> Result<PathBuf, Error>

Resolve the global config file path, honoring $GEST_CONFIG.

Parameter Type Description
returns Result<PathBuf, Error> $GEST_CONFIG when it is set, else gest/config.toml in the XDG config directory, or a config error when there is no such directory.

fn resolve_project_config_path

source

fn resolve_project_config_path() -> Result<PathBuf, Error>

Resolve the project config file path by walking ancestors of $CWD.

Returns the most-local existing .gest.toml or .config/gest.toml; falls back to $CWD/.gest.toml if no existing file is found.

Parameter Type Description
returns Result<PathBuf, Error> The config file path, which may not exist yet, or an error when $CWD cannot be read.

fn set_dot_path

source

fn set_dot_path(root: &mut Table, key: &str, value: Value)

Insert value at a dot-delimited path, creating intermediate tables as needed.

A non-table value on the way is replaced by an empty table.

Parameter Type Description
root &mut Table the config table to change
key &str the dot-delimited key, such as log.level
value Value the value to set at key