@@ -28,14 +28,16 @@ Options:
28
28
--permanent delete a file permanently
29
29
-d/--directory show path to the data dir
30
30
-t/--set-dir <dir> set the data dir and continue
31
+ -q/--quiet enable quiet mode
31
32
--disable-copy if files are on a different fs, don't rename by copy
32
33
-h/--help print this help message
33
34
-v/--version print Rem version`
34
35
dataDir string
35
36
logFileName = ".trash.log"
36
37
logFile map [string ]string
37
38
renameByCopyIsAllowed = true
38
- //logSeparator = "\t==>\t"
39
+
40
+ quietMode = false
39
41
)
40
42
41
43
// TODO: Multiple Rem instances could clobber log file. Fix using either file locks or tcp port locks.
@@ -84,6 +86,13 @@ func main() {
84
86
return
85
87
}
86
88
89
+ if hasOption , i := argsHaveOption ("quiet" , "q" ); hasOption {
90
+ quietMode = true
91
+ os .Args = removeElemFromSlice (os .Args , i )
92
+ main ()
93
+ return
94
+ }
95
+
87
96
if hasOption , _ := argsHaveOption ("directory" , "d" ); hasOption {
88
97
fmt .Println (dataDir )
89
98
return
@@ -144,7 +153,7 @@ func restore(path string) {
144
153
}
145
154
delete (logFile , absPath )
146
155
setLogFile (logFile ) // we deleted an entry so save the edited logFile
147
- fmt . Println (color .YellowString (path ) + " restored" )
156
+ printIfNotQuiet (color .YellowString (path ) + " restored" )
148
157
}
149
158
150
159
func trashFile (path string ) {
@@ -177,7 +186,7 @@ func trashFile(path string) {
177
186
setLogFile (m )
178
187
// if we've reached here, trashing is complete and successful
179
188
// TODO: Print with quotes only if it contains spaces
180
- fmt . Println ("Trashed " + color .YellowString (path ) + "\n Undo using " + color .YellowString ("rem --undo \" " + path + "\" " ))
189
+ printIfNotQuiet ("Trashed " + color .YellowString (path ) + "\n Undo using " + color .YellowString ("rem --undo \" " + path + "\" " ))
181
190
}
182
191
183
192
func renameByCopyAllowed (src , dst string ) error {
@@ -216,7 +225,7 @@ func getTimestampedPath(path string, existsFunc func(string) bool) string {
216
225
}
217
226
}
218
227
if i != 0 {
219
- fmt . Println ("To avoid conflicts, " + color .YellowString (oldPath ) + " will now be called " + color .YellowString (path ))
228
+ printIfNotQuiet ("To avoid conflicts, " + color .YellowString (oldPath ) + " will now be called " + color .YellowString (path ))
220
229
}
221
230
return path
222
231
}
@@ -383,3 +392,9 @@ func printFormattedList(a []string) {
383
392
fmt .Println (color .CyanString (strconv .Itoa (i + 1 )+ ":" ), elem )
384
393
}
385
394
}
395
+
396
+ func printIfNotQuiet (a ... interface {}) {
397
+ if ! quietMode {
398
+ fmt .Println (a ... )
399
+ }
400
+ }
0 commit comments