quick wins (issues #9 #10 #11 #12 #13 #16) : am logs (tail+follow), am list --running/--sort, am config set, am alias add/remove/list, dedup historique, am open
This commit is contained in:
@@ -25,7 +25,13 @@ struct AgentRow {
|
||||
}
|
||||
|
||||
/// run: installed agents only, unless all is set (whole catalog).
|
||||
pub fn run(app: &App, all: bool, category: Option<&str>) -> Result<i32> {
|
||||
pub fn run(
|
||||
app: &App,
|
||||
all: bool,
|
||||
category: Option<&str>,
|
||||
running: bool,
|
||||
sort: Option<&str>,
|
||||
) -> Result<i32> {
|
||||
let entries = app.state.all().unwrap_or_default();
|
||||
let probe = crate::probe::detect_externals(app);
|
||||
let mut rows: Vec<AgentRow> = Vec::new();
|
||||
@@ -43,7 +49,15 @@ pub fn run(app: &App, all: bool, category: Option<&str>) -> Result<i32> {
|
||||
if !all {
|
||||
rows.retain(|r| r.status == "running" || r.status == "installed" || r.status == "external");
|
||||
}
|
||||
rows.sort_by(|a, b| a.name.cmp(&b.name));
|
||||
if running {
|
||||
rows.retain(|r| r.status == "running");
|
||||
}
|
||||
match sort {
|
||||
Some("version") => rows.sort_by(|a, b| b.version.cmp(&a.version)),
|
||||
Some("status") => rows.sort_by(|a, b| a.status.cmp(&b.status)),
|
||||
Some(other) => bail!("invalid sort key '{other}' — expected name, version or status"),
|
||||
None => rows.sort_by(|a, b| a.name.cmp(&b.name)),
|
||||
}
|
||||
|
||||
if app.json() {
|
||||
print_json(&rows);
|
||||
|
||||
Reference in New Issue
Block a user