feat: added CLI --skill flag for modifying skills easily
This commit is contained in:
@@ -116,6 +116,12 @@ pub struct Cli {
|
|||||||
/// List all macros
|
/// List all macros
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub list_macros: bool,
|
pub list_macros: bool,
|
||||||
|
/// List all installed skills
|
||||||
|
#[arg(long)]
|
||||||
|
pub list_skills: bool,
|
||||||
|
/// Open a skill in $EDITOR (creates with a scaffold if missing)
|
||||||
|
#[arg(long, value_name = "NAME")]
|
||||||
|
pub skill: Option<String>,
|
||||||
/// Input text
|
/// Input text
|
||||||
#[arg(trailing_var_arg = true)]
|
#[arg(trailing_var_arg = true)]
|
||||||
text: Vec<String>,
|
text: Vec<String>,
|
||||||
@@ -298,6 +304,13 @@ mod tests {
|
|||||||
assert!(parse(&["--list-agents"]).list_agents);
|
assert!(parse(&["--list-agents"]).list_agents);
|
||||||
assert!(parse(&["--list-rags"]).list_rags);
|
assert!(parse(&["--list-rags"]).list_rags);
|
||||||
assert!(parse(&["--list-macros"]).list_macros);
|
assert!(parse(&["--list-macros"]).list_macros);
|
||||||
|
assert!(parse(&["--list-skills"]).list_skills);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_skill_flag_takes_name() {
|
||||||
|
assert_eq!(parse(&["--skill", "git-master"]).skill.as_deref(), Some("git-master"));
|
||||||
|
assert!(parse(&[]).skill.is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
+11
@@ -74,6 +74,7 @@ async fn main() -> Result<()> {
|
|||||||
|| cli.list_agents
|
|| cli.list_agents
|
||||||
|| cli.list_rags
|
|| cli.list_rags
|
||||||
|| cli.list_macros
|
|| cli.list_macros
|
||||||
|
|| cli.list_skills
|
||||||
|| cli.list_sessions;
|
|| cli.list_sessions;
|
||||||
let vault_flags = cli.add_secret.is_some()
|
let vault_flags = cli.add_secret.is_some()
|
||||||
|| cli.get_secret.is_some()
|
|| cli.get_secret.is_some()
|
||||||
@@ -191,6 +192,16 @@ async fn run(
|
|||||||
println!("{macros}");
|
println!("{macros}");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
if cli.list_skills {
|
||||||
|
let skills = paths::list_skills().join("\n");
|
||||||
|
println!("{skills}");
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
if let Some(name) = &cli.skill {
|
||||||
|
let app = Arc::clone(&ctx.app.config);
|
||||||
|
ctx.upsert_skill(app.as_ref(), name)?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
if cli.dry_run {
|
if cli.dry_run {
|
||||||
update_app_config(&mut ctx, |app| app.dry_run = true);
|
update_app_config(&mut ctx, |app| app.dry_run = true);
|
||||||
|
|||||||
Reference in New Issue
Block a user