11use crate :: config:: { self , Config , DestinationConfig } ;
22use crate :: detect:: ToolDetector ;
33use crate :: sync:: SyncManager ;
4- use crate :: tools:: all_tools;
4+ use crate :: tools:: { all_tools, get_tool } ;
55use anyhow:: { Result , anyhow} ;
66use clap:: { Parser , Subcommand } ;
77use std:: collections:: HashMap ;
@@ -26,6 +26,14 @@ pub enum Commands {
2626 DetectTools ,
2727 /// Sync skills to all enabled tools
2828 Sync ,
29+ /// Add a tool to configuration and sync
30+ Add {
31+ /// Tool name to add
32+ tool : String ,
33+ /// Skip syncing after adding
34+ #[ arg( long) ]
35+ no_sync : bool ,
36+ } ,
2937 /// Remove symlink from a tool (use --all to remove all)
3038 Remove {
3139 /// Tool name to remove symlink from (optional if --all is used)
@@ -46,6 +54,7 @@ pub fn run() -> Result<()> {
4654 Commands :: Config => show_config ( ) ,
4755 Commands :: DetectTools => detect_tools ( ) ,
4856 Commands :: Sync => sync_skills ( ) ,
57+ Commands :: Add { tool, no_sync } => add_tool ( & tool, no_sync) ,
4958 Commands :: Remove { tool, all } => {
5059 if all {
5160 remove_all ( )
@@ -203,6 +212,47 @@ fn remove_all() -> Result<()> {
203212 SyncManager :: remove_all ( & config)
204213}
205214
215+ fn add_tool ( tool_name : & str , no_sync : bool ) -> Result < ( ) > {
216+ let mut config = config:: load_config ( ) ?;
217+
218+ // Validate tool exists
219+ let tool = get_tool ( tool_name) . ok_or_else ( || {
220+ anyhow ! (
221+ "Tool '{}' does not exist or is unsupported in the current version" ,
222+ tool_name
223+ )
224+ } ) ?;
225+
226+ // Check if already in config
227+ if config. destinations . contains_key ( tool_name) {
228+ println ! ( "Tool '{}' is already in the configuration" , tool_name) ;
229+ if !no_sync {
230+ println ! ( "Running sync..." ) ;
231+ return sync_skills ( ) ;
232+ }
233+ return Ok ( ( ) ) ;
234+ }
235+
236+ // Add tool to config
237+ config. destinations . insert (
238+ tool_name. to_string ( ) ,
239+ DestinationConfig {
240+ enabled : true ,
241+ path : tool. skills_path ,
242+ } ,
243+ ) ;
244+
245+ config:: save_config ( & config) ?;
246+ println ! ( "Added '{}' to configuration" , tool_name) ;
247+
248+ if !no_sync {
249+ println ! ( "Running sync..." ) ;
250+ sync_skills ( )
251+ } else {
252+ Ok ( ( ) )
253+ }
254+ }
255+
206256fn show_status ( ) -> Result < ( ) > {
207257 let config = config:: load_config ( ) ?;
208258
0 commit comments