mirror of
https://github.com/fluencelabs/marine.git
synced 2024-12-12 06:45:32 +00:00
Add fce repl command (#15)
This commit is contained in:
parent
e0cbc92f2e
commit
31a15baf76
@ -63,3 +63,11 @@ pub fn show_wit<'a, 'b>() -> App<'a, 'b> {
|
||||
.short("i")
|
||||
.help("path to the Wasm file")])
|
||||
}
|
||||
|
||||
pub fn repl<'a, 'b>() -> App<'a, 'b> {
|
||||
SubCommand::with_name("repl")
|
||||
.about("Start Fluence application service REPL")
|
||||
.setting(clap::AppSettings::TrailingVarArg)
|
||||
.setting(clap::AppSettings::AllowLeadingHyphen)
|
||||
.arg(Arg::from_usage("[optional]... 'fluence repl arguments'").multiple(true))
|
||||
}
|
||||
|
@ -38,7 +38,8 @@ pub fn main() -> std::result::Result<(), anyhow::Error> {
|
||||
.setting(clap::AppSettings::ArgRequiredElseHelp)
|
||||
.subcommand(args::build())
|
||||
.subcommand(args::embed_wit())
|
||||
.subcommand(args::show_wit());
|
||||
.subcommand(args::show_wit())
|
||||
.subcommand(args::repl());
|
||||
let arg_matches = app.get_matches();
|
||||
|
||||
match arg_matches.subcommand() {
|
||||
@ -76,6 +77,25 @@ pub fn main() -> std::result::Result<(), anyhow::Error> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
("repl", Some(args)) => {
|
||||
use std::process::Command;
|
||||
// use UNIX-specific API for replacing process image
|
||||
use std::os::unix::process::CommandExt;
|
||||
|
||||
let trailing_args: Vec<&str> = args.values_of("optional").unwrap_or_default().collect();
|
||||
|
||||
let mut repl = Command::new("fce-repl");
|
||||
repl.args(trailing_args);
|
||||
let error = repl.exec();
|
||||
if error.kind() == std::io::ErrorKind::NotFound {
|
||||
println!("fce-repl not found, run `cargo +nightly install frepl` to install it");
|
||||
} else {
|
||||
// this branch should be executed if exec was successful, so just else if fine here
|
||||
println!("error occurred: {:?}", error);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
c => Err(crate::errors::CLIError::NoSuchCommand(c.0.to_string()).into()),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user