pub struct EnvArgs {
pub config_file_path: Option<String>,
pub port: Option<u16>,
pub fallback_respond_dir_path: Option<String>,
}Expand description
CLI arguments parsed at process start-up.
§Why these three fields are the only command-line surface
apimock deliberately keeps its CLI tiny: config-file path, port,
fallback respond dir. Anything richer than that belongs in the TOML
config so that it can be checked in with the rest of the mock setup
and reproduced between machines. The three CLI flags exist only for
quick ad-hoc overrides that don’t warrant editing the config file.
Fields§
§config_file_path: Option<String>path to the config TOML file (usually ./apimock.toml)
port: Option<u16>overrides listener.port in the config file
fallback_respond_dir_path: Option<String>overrides service.fallback_respond_dir in the config file
Implementations§
Source§impl EnvArgs
impl EnvArgs
Sourcepub fn default() -> AppResult<Option<Self>>
pub fn default() -> AppResult<Option<Self>>
Parse env::args() and apply defaults.
Returns:
Ok(Some(args))for the normal “start the server” path,Ok(None)when a meta command (e.g.--init) has already completed its side effect and the process should exit cleanly,Err(_)when an argument was malformed or a referenced file is missing.
§Why return AppResult<Option<_>> instead of panicking
Previously invalid arguments triggered panic!, which printed a
backtrace for a user-level error. Returning a typed error lets the
binary print “invalid port: foo” and exit 1, which is what users
of CLI tools actually expect.