@@ -939,11 +939,11 @@ cp plugin.toml ~/.cortex/plugins/{}/
939939
940940impl PluginCli {
941941 /// Run the plugin command.
942- pub async fn run ( self ) -> Result < ( ) > {
942+ pub async fn run ( self , verbose : bool ) -> Result < ( ) > {
943943 match self . subcommand {
944944 PluginSubcommand :: List ( args) => run_list ( args) . await ,
945945 PluginSubcommand :: Install ( args) => run_install ( args) . await ,
946- PluginSubcommand :: Remove ( args) => run_remove ( args) . await ,
946+ PluginSubcommand :: Remove ( args) => run_remove ( args, verbose ) . await ,
947947 PluginSubcommand :: Enable ( args) => run_enable ( args) . await ,
948948 PluginSubcommand :: Disable ( args) => run_disable ( args) . await ,
949949 PluginSubcommand :: Show ( args) => run_show ( args) . await ,
@@ -1143,7 +1143,7 @@ fn copy_dir_recursive(src: &std::path::Path, dst: &std::path::Path) -> Result<()
11431143 Ok ( ( ) )
11441144}
11451145
1146- async fn run_remove ( args : PluginRemoveArgs ) -> Result < ( ) > {
1146+ async fn run_remove ( args : PluginRemoveArgs , verbose : bool ) -> Result < ( ) > {
11471147 let plugins_dir = get_plugins_dir ( ) ;
11481148 let plugin_path = plugins_dir. join ( & args. name ) ;
11491149
@@ -1164,11 +1164,49 @@ async fn run_remove(args: PluginRemoveArgs) -> Result<()> {
11641164 }
11651165 }
11661166
1167+ if verbose {
1168+ for line in plugin_remove_verbose_preflight_lines ( & plugin_path, args. yes ) {
1169+ println ! ( "{line}" ) ;
1170+ }
1171+ }
1172+
11671173 std:: fs:: remove_dir_all ( & plugin_path) ?;
11681174 println ! ( "Plugin '{}' removed successfully." , args. name) ;
1175+
1176+ if verbose {
1177+ for line in plugin_remove_verbose_completion_lines ( & plugin_path, & plugins_dir) {
1178+ println ! ( "{line}" ) ;
1179+ }
1180+ }
1181+
11691182 Ok ( ( ) )
11701183}
11711184
1185+ fn plugin_remove_verbose_preflight_lines ( plugin_path : & Path , yes : bool ) -> Vec < String > {
1186+ vec ! [
1187+ format!( "Plugin directory: {}" , plugin_path. display( ) ) ,
1188+ format!(
1189+ "Confirmation: {}" ,
1190+ if yes {
1191+ "skipped (--yes)"
1192+ } else {
1193+ "confirmed by prompt"
1194+ }
1195+ ) ,
1196+ ]
1197+ }
1198+
1199+ fn plugin_remove_verbose_completion_lines ( plugin_path : & Path , plugins_dir : & Path ) -> Vec < String > {
1200+ vec ! [
1201+ format!( "Removed path: {}" , plugin_path. display( ) ) ,
1202+ format!(
1203+ "Plugin exists after removal: {}" ,
1204+ if plugin_path. exists( ) { "yes" } else { "no" }
1205+ ) ,
1206+ format!( "Plugins directory: {}" , plugins_dir. display( ) ) ,
1207+ ]
1208+ }
1209+
11721210async fn run_enable ( args : PluginEnableArgs ) -> Result < ( ) > {
11731211 let plugins_dir = get_plugins_dir ( ) ;
11741212 let plugin_path = plugins_dir. join ( & args. name ) ;
@@ -2458,6 +2496,35 @@ mod tests {
24582496 assert ! ( args. yes, "yes should be true when set" ) ;
24592497 }
24602498
2499+ #[ test]
2500+ fn test_plugin_remove_verbose_lines_include_extra_context ( ) {
2501+ let plugins_dir = PathBuf :: from ( "cortex-plugins" ) ;
2502+ let plugin_path = plugins_dir. join ( "remove-me" ) ;
2503+
2504+ let preflight = plugin_remove_verbose_preflight_lines ( & plugin_path, true ) ;
2505+ assert_eq ! (
2506+ preflight,
2507+ vec![
2508+ format!( "Plugin directory: {}" , plugin_path. display( ) ) ,
2509+ "Confirmation: skipped (--yes)" . to_string( ) ,
2510+ ]
2511+ ) ;
2512+
2513+ let completion = plugin_remove_verbose_completion_lines ( & plugin_path, & plugins_dir) ;
2514+ assert ! (
2515+ completion
2516+ . iter( )
2517+ . any( |line| line == & format!( "Removed path: {}" , plugin_path. display( ) ) ) ,
2518+ "completion output should include the removed plugin path"
2519+ ) ;
2520+ assert ! (
2521+ completion
2522+ . iter( )
2523+ . any( |line| line == & format!( "Plugins directory: {}" , plugins_dir. display( ) ) ) ,
2524+ "completion output should include the parent plugin directory"
2525+ ) ;
2526+ }
2527+
24612528 // ==========================================================================
24622529 // CLI argument parsing tests - PluginEnableArgs / PluginDisableArgs
24632530 // ==========================================================================
0 commit comments