loopd, bxctl, inferproxy: read args_os instead of panicking
M3a review finding 7, for the other three roles. loopd keeps its config path as a path; bxctl and inferproxy take text arguments and answer one that is not UTF-8 with their usage. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,19 @@ use bxctl::escape::escape_model_text;
|
||||
use proto::{ErrorCode, SessionId, Timestamp, TurnDone};
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
// `args_os`, because `args` panics on an argument that is not UTF-8. bxctl's arguments are
|
||||
// text (ids, messages, paths it prints back), so such an argument is a usage error.
|
||||
let args: Vec<String> = match std::env::args_os()
|
||||
.skip(1)
|
||||
.map(|a| a.into_string())
|
||||
.collect()
|
||||
{
|
||||
Ok(args) => args,
|
||||
Err(_) => {
|
||||
eprintln!("bxctl: an argument is not valid UTF-8\n{USAGE}");
|
||||
return ExitCode::from(2);
|
||||
}
|
||||
};
|
||||
// $BOXMAKER_HOME defaults to /var/lib/boxmaker; defaults for the sockets are read from it.
|
||||
let home = std::env::var_os("BOXMAKER_HOME")
|
||||
.map(PathBuf::from)
|
||||
|
||||
Reference in New Issue
Block a user