events : instrumentation start/stop/run/install/update/uninstall/doctor/repl/shell (issue #3) - un evenement JSONL par action reelle, dry-run sans evenement, session id sur start, duree et exit code sur stop/run
This commit is contained in:
+14
@@ -15,6 +15,7 @@
|
||||
use crate::app::App;
|
||||
use crate::cli::{Command, StartArgs};
|
||||
use crate::commands;
|
||||
use crate::events::{Event, EventKind};
|
||||
use crate::nav;
|
||||
use crate::ps;
|
||||
use crate::tables::DataTable;
|
||||
@@ -884,6 +885,11 @@ pub fn run(app: &App) -> Result<i32> {
|
||||
}
|
||||
let mut session = ShellSession::start(&app.config);
|
||||
let sid = session_id();
|
||||
app.emit(
|
||||
&Event::now(EventKind::Repl)
|
||||
.with_session(sid.clone())
|
||||
.with_cwd(Some(current_dir_string())),
|
||||
);
|
||||
print!("{}", banner(app, &session, &sid));
|
||||
match run_with_editor(app, &mut session) {
|
||||
Ok(code) => Ok(code),
|
||||
@@ -1379,11 +1385,19 @@ fn eval_pipeline(app: &App, last: &mut Option<DataTable>, line: &str) -> Result<
|
||||
/// Run one system command through the active shell (inherited stdio).
|
||||
fn run_system(app: &App, session: &ShellSession, line: &str) -> Result<()> {
|
||||
app.log.cmd(&format!("{}: {line}", session.current.name));
|
||||
let started = std::time::Instant::now();
|
||||
let code = session.run(line)?;
|
||||
if code != 0 {
|
||||
app.log
|
||||
.error(&format!("command exited with code {code}"));
|
||||
}
|
||||
app.emit(
|
||||
&Event::now(EventKind::Shell)
|
||||
.with_args(vec![line.to_string()])
|
||||
.with_exit_code(code)
|
||||
.with_duration(started.elapsed().as_secs())
|
||||
.with_cwd(Some(current_dir_string())),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user