@@ -10,13 +10,16 @@ static void Main(string[] args)
1010
1111 Alias alias_history = new Alias ( [ "--his" , "--h" , "-h" , "-history" , "-his" , "--history" ] ) ;
1212 Alias alias_restore = new Alias ( [ "--res" , "--r" , "-r" , "-restore" , "-res" , "--restore" ] ) ;
13+ Alias alias_permanent = new Alias ( [ "-p" , "--permament" , "--permanent" ] ) ;
14+
1315
1416 if ( args . Length == 0 )
1517 {
16- Console . WriteLine ( "Usage:" ) ;
17- Console . WriteLine ( $ " --history (ALIASES: { alias_history . ToString ( ) } )") ;
18- Console . WriteLine ( $ " --restore <ID|VERSION> <FILENAME> (ALIASES: { alias_restore . ToString ( ) } )") ;
19- Console . WriteLine ( " <files...> to trash" ) ;
18+ Utils . WrteLineColor ( "Usage:" , ConsoleColor . Green ) ;
19+ Utils . WrteLineColor ( $ " --history (ALIASES: { alias_history . ToString ( ) } )", ConsoleColor . DarkGreen ) ;
20+ Utils . WrteLineColor ( $ " --permament <files...> (ALIASES: { alias_permanent . ToString ( ) } )", ConsoleColor . DarkGreen ) ;
21+ Utils . WrteLineColor ( $ " --restore <ID|VERSION> <FILENAME> (ALIASES: { alias_restore . ToString ( ) } )", ConsoleColor . DarkGreen ) ;
22+ Utils . WrteLineColor ( " <files...> to trash" , ConsoleColor . DarkGreen ) ;
2023 return ;
2124 }
2225
@@ -38,6 +41,16 @@ static void Main(string[] args)
3841
3942 Restore ( args [ 1 ] , args [ 2 ] ) ;
4043 }
44+ else if ( alias_permanent . Have ( args [ 0 ] ) )
45+ {
46+ if ( args . Length < 2 )
47+ {
48+ Utils . WrteLineColor ( "Error: --permament requires at least one file or folder" , ConsoleColor . Red ) ;
49+ return ;
50+ }
51+
52+ PermanentDelete ( args . Skip ( 1 ) . ToArray ( ) ) ;
53+ }
4154 else if ( args [ 0 ] . StartsWith ( "-" ) ) // Unknown flag
4255 {
4356 Utils . WrteLineColor ( $ "Unknown option: { args [ 0 ] } ", ConsoleColor . Red ) ;
@@ -50,6 +63,43 @@ static void Main(string[] args)
5063
5164 }
5265
66+ static void PermanentDelete ( string [ ] paths )
67+ {
68+ Utils . WrteLineColor ( "WARNING: Permanent deletion cannot be undone!" , ConsoleColor . Yellow ) ;
69+ Utils . WrteLineColor ( "Are you Sure? (y/n)" , ConsoleColor . Red ) ;
70+
71+ string ? answer = Console . ReadLine ( ) ;
72+
73+ if ( answer == "" ) return ;
74+ else if ( answer . ToLower ( ) == "y" ) { }
75+
76+ foreach ( var path in paths )
77+ {
78+ try
79+ {
80+ if ( File . Exists ( path ) )
81+ {
82+ File . Delete ( path ) ;
83+ Utils . WrteLineColor ( $ "Permanently deleted file '{ path } '", ConsoleColor . Red ) ;
84+ }
85+ else if ( Directory . Exists ( path ) )
86+ {
87+ Directory . Delete ( path , true ) ;
88+ Utils . WrteLineColor ( $ "Permanently deleted directory '{ path } '", ConsoleColor . Red ) ;
89+ }
90+ else
91+ {
92+ Console . WriteLine ( $ "Path not found: { path } ") ;
93+ }
94+ }
95+ catch ( Exception ex )
96+ {
97+ Utils . WrteLineColor ( $ "Failed to delete '{ path } ': { ex . Message } ", ConsoleColor . Red ) ;
98+ }
99+ }
100+ }
101+
102+
53103 class Alias
54104 {
55105 private string [ ] _names = [ ] ;
@@ -168,7 +218,7 @@ static void History()
168218
169219 string line = $ "{ entry . Id , - 4 } | { entry . Version , - 20 } | { contents } ";
170220 if ( i == 0 )
171- PrintRed ( line + " (LAST DELETED )" ) ;
221+ PrintRed ( line + " (LAST TEMPED )" ) ;
172222 else
173223 PrintRedIdOnly ( entry . Id , line ) ;
174224 }
0 commit comments