Start implementing scenario run().
Add different template string char.
This commit is contained in:
parent
54adfe5095
commit
c73ce95fd9
|
@ -1,5 +1,7 @@
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, SimplePluginCommand};
|
||||||
use nu_protocol::{record, Category, Example, LabeledError, Signature, Value};
|
use nu_protocol::{
|
||||||
|
record, Category, Example, IntoSpanned, LabeledError, PipelineData, Signature, Spanned, Value,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::OncePlugin;
|
use crate::OncePlugin;
|
||||||
|
|
||||||
|
@ -44,27 +46,42 @@ impl SimplePluginCommand for Scenario {
|
||||||
fn run(
|
fn run(
|
||||||
&self,
|
&self,
|
||||||
_plugin: &OncePlugin,
|
_plugin: &OncePlugin,
|
||||||
_engine: &EngineInterface,
|
engine: &EngineInterface,
|
||||||
call: &EvaluatedCall,
|
call: &EvaluatedCall,
|
||||||
_input: &Value,
|
_input: &Value,
|
||||||
) -> Result<Value, LabeledError> {
|
) -> Result<Value, LabeledError> {
|
||||||
let head = call.head;
|
let head = call.head;
|
||||||
let list = vec![
|
|
||||||
Value::record(
|
const SCENARIO_SOURCE_PATH: &str = "/workspaces/Once.2023/Scenarios";
|
||||||
record! {
|
let name: Spanned<String> = Spanned {
|
||||||
"name" => Value::test_string("dev"),
|
span: head,
|
||||||
"filename" => Value::test_string("dev.scenario.env")
|
item: "glob".to_owned(),
|
||||||
},
|
};
|
||||||
|
let decl_id = engine.find_decl(&name.item)?.ok_or_else(|| {
|
||||||
|
LabeledError::new(format!("Can't find `{}`", name.item))
|
||||||
|
.with_label("not in scope", name.span)
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let mut new_call = EvaluatedCall::new(call.head);
|
||||||
|
//new_call.add_flag("l".into_spanned(head));
|
||||||
|
new_call.add_positional(Value::string(
|
||||||
|
format!("{}/**/*.{{scenario,env}}", SCENARIO_SOURCE_PATH),
|
||||||
head,
|
head,
|
||||||
),
|
));
|
||||||
Value::record(
|
// TODO: Filter out localhost is not working yet
|
||||||
record! {
|
new_call.add_named(
|
||||||
"name" => Value::test_string("certbot"),
|
"exclude".into_spanned(head),
|
||||||
"filename" => Value::test_string("certbot.scenario.env")
|
Value::string("[**/localhost/*]", head),
|
||||||
},
|
);
|
||||||
head,
|
|
||||||
),
|
let result: PipelineData =
|
||||||
];
|
engine.call_decl(decl_id, new_call, PipelineData::Empty, true, false)?;
|
||||||
|
|
||||||
|
let mut list = vec![];
|
||||||
|
for res in result.into_iter() {
|
||||||
|
list.push(res);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Value::list(list, head))
|
Ok(Value::list(list, head))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ impl SimplePluginCommand for ScenarioDeploy {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extra_usage(&self) -> &str {
|
fn extra_usage(&self) -> &str {
|
||||||
r" Lifecycle actions:
|
r#" Lifecycle actions:
|
||||||
init - init remote scenario dir
|
init - init remote scenario dir
|
||||||
up - Create and start scenario
|
up - Create and start scenario
|
||||||
stop - Stop scenario
|
stop - Stop scenario
|
||||||
|
@ -27,7 +27,7 @@ impl SimplePluginCommand for ScenarioDeploy {
|
||||||
|
|
||||||
Service actions:
|
Service actions:
|
||||||
test - Test the running scenario
|
test - Test the running scenario
|
||||||
updateconfig - update local scenario config"
|
updateconfig - update local scenario config"#
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user