use std::cell::RefCell;
use std::cell::Cell;
+type E = anyhow::Error;
+
use argparse::action::ParseResult::Parsed;
#[derive(Clone)]
struct Subcommand (
&'static str, // command
&'static str, // desc
- fn(&Subcommand, MainOpts, Vec<String>),
+ fn(&Subcommand, MainOpts, Vec<String>) -> Result<(),E>,
);
inventory::collect!(Subcommand);
env::args().next().unwrap(),
&ma.subcommand));
- call(sc, ma.opts, subargs);
+ call(sc, ma.opts, subargs).expect("execution error");
+}
+
+type Conn = MgmtChannel<UnixStream>;
+
+fn connect(ma: &MainOpts) -> Result<(),E> {
+ let unix = UnixStream::connect(SOCKET_PATH).context("connect to server")?;
+
+ todo!()
}
inventory::submit!{Subcommand(
Ok(())
}, None);
- eprintln!("CREATE-TABLE {:?} {:?}", &mainopts, &args);
+ let chan = connect(&mainopts)?;
+
+ eprintln!("CREATE-TABLE {:?} {:?} {:?}", &mainopts, &args, &chan);
+ Ok(())
}
)}
-
-use crate::imports::*;
-
-pub struct MgmtConnection {
- read : io::Lines<BufReader<UnixStream>>,
- write : BufWriter<UnixStream>,
-}
-
-impl MgmtConnection {
- fn connect() {
- todo!();
-// let mut both = UnixStream:;connect(SOCKET_PATH)?;
- }
-}
//use serde_json::ser::Serializer;
//use serde_json::de::{IoRead,StreamDeserializer};
-const SOCKET_PATH : &str = "command.socket"; // xxx
+pub const SOCKET_PATH : &str = "command.socket"; // xxx
pub struct CommandListener {
listener : UnixListener,
}
}
-trait IoTryClone : Sized {
+pub trait IoTryClone : Sized {
fn try_clone(&self) -> io::Result<Self>;
}
#[typetag::serde(tag="access")]
pub trait PlayerAccessSpec : Debug {
- fn deliver_token_client(&self, conn: &mut MgmtConnection, nick: &str)
+ fn deliver_token_client(&self, conn: &mut ()/*xxx*/, nick: &str)
-> Result<(),anyhow::Error>;
}
#[typetag::serde]
impl PlayerAccessSpec for UrlOnStdout {
- fn deliver_token_client(&self, conn: &mut MgmtConnection, nick: &str)
+ fn deliver_token_client(&self, conn: &mut (), nick: &str)
-> Result<(),anyhow::Error> {
todo!()
}