subing works, although be it very prototype like
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
use clap::ArgMatches;
|
||||
use mize::error::MizeResult;
|
||||
use crossbeam::channel::{bounded, unbounded};
|
||||
use mize::error::{MizeResult, MizeError};
|
||||
use mize::instance::subscription::{Subscription, Update};
|
||||
use mize::instance::Instance;
|
||||
use mize::platform::os::config_from_cli_args;
|
||||
|
||||
pub fn show(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
|
||||
let instance = Instance::new()?;
|
||||
let instance = Instance::with_config(config_from_cli_args(sub_matches)?)?;
|
||||
|
||||
println!("0/config/test is: {}", instance.get("0/config/test")?);
|
||||
let id = sub_matches.get_one::<String>("id")
|
||||
.ok_or(MizeError::new().msg("No id Argument specified"))?;
|
||||
|
||||
let item = instance.get(id)?;
|
||||
|
||||
let (tx, rx) = bounded::<Update>(4);
|
||||
let sub = Subscription::from_sender(tx);
|
||||
instance.sub(id, sub)?;
|
||||
|
||||
println!("ItemData: {}", item.as_data_full()?);
|
||||
|
||||
for update in rx {
|
||||
println!("####### GOT UPDATE #######");
|
||||
println!("ItemData: {}", update.new_item()?.as_data_full()?);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ pub fn os_instance_init(instance: &mut Instance) -> MizeResult<()> {
|
||||
Ok(config_file_path) => {
|
||||
let config = config_from_file(config_file_path)?;
|
||||
debug!("env var MIZE_CONFIG_FILE present");
|
||||
instance.set("0", config)?;
|
||||
instance.set_blocking("0", config)?;
|
||||
trace!("config after MIZE_CONFIG_FILE env var: {}", instance.get("0/config")?);
|
||||
}
|
||||
Err(var_err) => match var_err {
|
||||
@@ -48,7 +48,7 @@ pub fn os_instance_init(instance: &mut Instance) -> MizeResult<()> {
|
||||
Ok(config_string) => {
|
||||
let config = config_from_string(config_string)?;
|
||||
debug!("env var MIZE_CONFIG present");
|
||||
instance.set("0", config)?;
|
||||
instance.set_blocking("0", config)?;
|
||||
trace!("config after MIZE_CONFIG env var: {}", instance.get("0/config")?);
|
||||
}
|
||||
Err(var_err) => match var_err {
|
||||
@@ -62,6 +62,8 @@ pub fn os_instance_init(instance: &mut Instance) -> MizeResult<()> {
|
||||
};
|
||||
|
||||
////// if a config.store_path is set, upgrade to the filestore there
|
||||
let mut test = instance.get("0")?.as_data_full()?;
|
||||
println!("os::Mod test: {}", test);
|
||||
let mut store_path = instance.get("0/config/store_path")?.value_string()?;
|
||||
|
||||
if store_path == "" {
|
||||
|
||||
Reference in New Issue
Block a user