@@ -23,6 +23,7 @@ public static void PrintUsage() => Console.WriteLine("""
2323 --org <name|url> --project <name> --team <name> --connection <name>
2424 --pat-stdin (read the PAT from standard input) --default (make it the default connection)
2525 logout remove the stored PAT of a connection --connection <name> | --all
26+ --remove: also the connection itself and its metadata cache
2627 connections list the connections
2728 config show or change settings
2829 --connection <name> --project <name> --team <name> (defaults of a connection)
@@ -196,6 +197,23 @@ public int Logout()
196197 Console . WriteLine ( CredentialStore . Delete ( name )
197198 ? $ "removed { CredentialStore . TargetFor ( name ) } from Windows Credential Manager"
198199 : $ "no stored PAT for connection '{ name } '") ;
200+ if ( ! cl . Flag ( "remove" ) ) return 0 ;
201+
202+ // --remove: the whole connection - settings entry and its metadata cache, not only the PAT.
203+ var key = settings . Connections . Keys . FirstOrDefault ( k => k . Equals ( name , StringComparison . OrdinalIgnoreCase ) ) ;
204+ if ( key is null ) { Console . WriteLine ( $ "no connection '{ name } ' in the settings") ; return 0 ; }
205+ settings . Connections . Remove ( key ) ;
206+ if ( string . Equals ( settings . DefaultConnection , key , StringComparison . OrdinalIgnoreCase ) )
207+ settings . DefaultConnection = settings . Connections . Count == 1 ? settings . Connections . Keys . First ( ) : null ;
208+ settings . Save ( SettingsPath ) ;
209+ Console . WriteLine ( $ "removed connection '{ key } ' from { SettingsPath } " +
210+ ( settings . DefaultConnection is { } d ? $ "; default connection: { d } " : settings . Connections . Count > 1 ? "; set a default with 'adolens config --default-connection <name>'" : "" ) ) ;
211+ var meta = Path . Combine ( Settings . DataDir , "meta" ) ;
212+ foreach ( var f in Directory . Exists ( meta ) ? Directory . GetFiles ( meta , key + ".db*" ) : [ ] )
213+ {
214+ try { File . Delete ( f ) ; }
215+ catch ( IOException ) { Console . WriteLine ( $ "note: { f } is in use (an open Claude session) - delete it later") ; }
216+ }
199217 return 0 ;
200218 }
201219
@@ -443,6 +461,14 @@ public async Task<int> UpdateAsync()
443461 Tags = cl . Opt ( "tags" ) , Fields = FieldOptions ( ) ,
444462 } ;
445463 var ids = cl . Opt ( "ids" ) ?? ( cl . Positional . Count > 0 ? string . Join ( ';' , cl . Positional ) : null ) ;
464+ var wiql = cl . Peek ( "wiql" ) ;
465+ if ( ids is null && wiql is null && r . IsEmpty && cl . Peek ( "comment" ) is null )
466+ {
467+ // "update" alone is easily taken for updating the program.
468+ Console . Error . WriteLine ( "update changes work items: adolens update <ids> --state <s> | --field \" Name=Value\" | --comment <text>…" ) ;
469+ Console . Error . WriteLine ( "to update ADO Lens itself: adolens upgrade --install" ) ;
470+ return 2 ;
471+ }
446472 Print ( await WorkQueries . UpdateAsync ( lens , cl . Opt ( "connection" ) , ids , cl . Opt ( "wiql" ) , r , cl . Opt ( "comment" ) , cl . Opt ( "confirm" ) , lens . Settings . ConfirmBulkAbove ) ) ;
447473 return 0 ;
448474 }
0 commit comments