memoryd: the crate, memoryd.toml, and listening on a socket
Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
//! `memoryd serve --config <path>`.
|
||||
|
||||
use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
use std::process::ExitCode;
|
||||
|
||||
const USAGE: &str = "usage: memoryd serve --config <path>";
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let args: Vec<OsString> = std::env::args_os().skip(1).collect();
|
||||
let Some(config) = parse(&args) else {
|
||||
eprintln!("{USAGE}");
|
||||
return ExitCode::from(2);
|
||||
};
|
||||
match memoryd::config::Config::load(&config) {
|
||||
Ok(_) => {
|
||||
eprintln!("memoryd: not implemented");
|
||||
ExitCode::from(2)
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("memoryd: {e}\nsee docs/runbook.md#memoryd-start-failed");
|
||||
ExitCode::from(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The config path of `serve --config <path>`, or `None` for any other list.
|
||||
fn parse(args: &[OsString]) -> Option<PathBuf> {
|
||||
match args {
|
||||
[serve, flag, path] if serve == "serve" && flag == "--config" => Some(PathBuf::from(path)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user