added ppc server and mize run external subcommands
This commit is contained in:
@@ -2,7 +2,7 @@ use clap::ArgMatches;
|
||||
use core::result::Result::Err;
|
||||
use core::unimplemented;
|
||||
use mize::flume::bounded;
|
||||
use mize::mize_err;
|
||||
use mize::{instance, mize_err};
|
||||
use std::ffi::OsString;
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
@@ -18,8 +18,7 @@ use mize::item::{IntoItemData, ItemData};
|
||||
use mize::platform::os::config_from_cli_args;
|
||||
use mize::platform::os::fsstore::FileStore;
|
||||
|
||||
pub fn get(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
let instance = Mize::with_config(config_from_cli_args(sub_matches)?)?;
|
||||
pub fn get(sub_matches: &ArgMatches, instance: &mut Mize) -> MizeResult<()> {
|
||||
|
||||
let id = sub_matches
|
||||
.get_one::<String>("id")
|
||||
@@ -42,13 +41,12 @@ pub fn get(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
pub fn call(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
pub fn call(sub_matches: &ArgMatches, instance: &mut Mize) -> MizeResult<()> {
|
||||
println!("call cmd not implemented");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
let mut instance = Mize::with_config(config_from_cli_args(sub_matches)?)?;
|
||||
pub fn create(sub_matches: &ArgMatches, instance: &mut Mize) -> MizeResult<()> {
|
||||
|
||||
let item = instance.new_item()?;
|
||||
|
||||
@@ -58,27 +56,37 @@ pub fn create(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
pub fn status(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
pub fn status(sub_matches: &ArgMatches, instance: &mut Mize) -> MizeResult<()> {
|
||||
println!("not implemented");
|
||||
Err(mize_err!("not implemented"))
|
||||
}
|
||||
|
||||
pub fn info(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
pub fn info(sub_matches: &ArgMatches, instance: &mut Mize) -> MizeResult<()> {
|
||||
println!("not implemented");
|
||||
Err(mize_err!("not implemented"))
|
||||
}
|
||||
|
||||
pub fn run(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
let instance = Mize::with_config(config_from_cli_args(sub_matches)?)?;
|
||||
pub fn run(sub_matches: &ArgMatches, instance: &mut Mize) -> MizeResult<()> {
|
||||
match sub_matches.subcommand() {
|
||||
None => {
|
||||
instance.wait();
|
||||
}
|
||||
Some((runnable, sub_matches)) => {
|
||||
let ext_args: Vec<String> = sub_matches
|
||||
.get_many::<OsString>("")
|
||||
.unwrap_or_default()
|
||||
.map(|v| v.to_string_lossy().to_string())
|
||||
.collect();
|
||||
|
||||
println!("runnable: {}", runnable);
|
||||
println!("args: {:?}", ext_args);
|
||||
}
|
||||
}
|
||||
|
||||
instance.wait();
|
||||
|
||||
return Ok(());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
let instance = Mize::with_config(config_from_cli_args(sub_matches)?)?;
|
||||
|
||||
pub fn set(sub_matches: &ArgMatches, instance: &mut Mize) -> MizeResult<()> {
|
||||
let id = sub_matches
|
||||
.get_one::<String>("id")
|
||||
.ok_or(MizeError::new().msg("No id Argument specified"))?;
|
||||
@@ -92,7 +100,7 @@ pub fn set(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn show(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
pub fn show(sub_matches: &ArgMatches, instance: &mut Mize) -> MizeResult<()> {
|
||||
println!("not implemented");
|
||||
// let instance = Mize::with_config(config_from_cli_args(sub_matches)?)?;
|
||||
|
||||
@@ -116,7 +124,7 @@ pub fn show(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn format_cbor(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
pub fn format_cbor(sub_matches: &ArgMatches, instance: &mut Mize) -> MizeResult<()> {
|
||||
let mut input: Vec<u8> = Vec::new();
|
||||
let stdin = std::io::stdin();
|
||||
let mut handle = stdin.lock();
|
||||
@@ -130,7 +138,7 @@ pub fn format_cbor(sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn run_from_part(cmd: &str, sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
pub fn run_from_part(cmd: &str, sub_matches: &ArgMatches, instance: &mut Mize) -> MizeResult<()> {
|
||||
let default = OsString::default();
|
||||
let mut sub_cmd_line: Vec<OsString> = sub_matches
|
||||
.get_many::<OsString>("")
|
||||
@@ -139,8 +147,6 @@ pub fn run_from_part(cmd: &str, sub_matches: &ArgMatches) -> MizeResult<()> {
|
||||
.collect();
|
||||
sub_cmd_line.insert(0, OsString::from_str(cmd)?);
|
||||
|
||||
let mut instance = Mize::with_config(config_from_cli_args(sub_matches)?)?;
|
||||
|
||||
debug!("loading module '{}'", cmd);
|
||||
instance.load_part(cmd)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user