@@ -35,7 +35,7 @@ const (
35
35
type CommandLineOptions struct {
36
36
DryRun bool `short:"n" long:"dry-run" description:"Don't rename anything but show the operation that would have been performed."`
37
37
Verbose bool `short:"v" long:"verbose" description:"Enable verbose output."`
38
- Config bool `short:"c" long:"config" description:"Set or list a configuration values. For more info: massren --config --help"`
38
+ Config bool `short:"c" long:"config" description:"Set or list configuration values. For more info: massren --config --help"`
39
39
Undo bool `short:"u" long:"undo" description:"Undo a rename operation. Currently delete operations cannot be undone (though files can be recovered from the trash in OSX and Windows). eg. massren --undo [path]"`
40
40
Version bool `short:"V" long:"version" description:"Displays version information."`
41
41
}
@@ -193,7 +193,7 @@ func editFile(filePath string) error {
193
193
return nil
194
194
}
195
195
196
- func filePathsFromArgs (args []string ) ([]string , error ) {
196
+ func filePathsFromArgs (args []string , includeDirectories bool ) ([]string , error ) {
197
197
var output []string
198
198
var err error
199
199
@@ -218,6 +218,18 @@ func filePathsFromArgs(args []string) ([]string, error) {
218
218
}
219
219
}
220
220
221
+ if ! includeDirectories {
222
+ var temp []string
223
+ for _ , path := range output {
224
+ f , err := os .Stat (path )
225
+ if err == nil && f .IsDir () {
226
+ continue
227
+ }
228
+ temp = append (temp , path )
229
+ }
230
+ output = temp
231
+ }
232
+
221
233
sort .Strings (output )
222
234
223
235
return output , nil
@@ -262,12 +274,12 @@ func filePathsFromListFile(filePath string) ([]string, error) {
262
274
return filePathsFromString (string (contentB )), nil
263
275
}
264
276
265
- func printHelp (subMenu string ) {
277
+ func printHelp (subMenu string ) {
266
278
var info string
267
-
279
+
268
280
if subMenu == "" {
269
281
flagParser_ .WriteHelp (os .Stdout )
270
-
282
+
271
283
info = `
272
284
Examples:
273
285
@@ -301,8 +313,10 @@ Config commands:
301
313
302
314
Possible key/values:
303
315
304
- editor: The editor to use when editing the list of files. Default: auto-detected.
305
- use_trash: Whether files should be moved to the trash/recycle bin after deletion. Possible values: 0 or 1. Default: 1.
316
+ editor: The editor to use when editing the list of files. Default: auto-detected.
317
+ use_trash: Whether files should be moved to the trash/recycle bin after deletion. Possible values: 0 or 1. Default: 1.
318
+ include_directories: Whether to include the directories the file buffer. Possible values: 0 or 1. Default: 1.
319
+ include_header: Whether to show the header in the file buffer. Possible values: 0 or 1. Default: 1.
306
320
307
321
Examples:
308
322
@@ -313,7 +327,7 @@ Examples:
313
327
% APPNAME --config use_trash 0
314
328
`
315
329
}
316
-
330
+
317
331
fmt .Println (strings .Replace (info , "APPNAME" , APPNAME , - 1 ))
318
332
}
319
333
@@ -444,7 +458,7 @@ func processFileActions(fileActions []*FileAction, dryRun bool) error {
444
458
logError ("Could not save history items: %s" , err )
445
459
}
446
460
}()
447
-
461
+
448
462
var deleteWaitGroup sync.WaitGroup
449
463
var deleteChannel = make (chan int , 100 )
450
464
useTrash := config_ .Bool ("use_trash" )
@@ -495,7 +509,7 @@ func processFileActions(fileActions []*FileAction, dryRun bool) error {
495
509
if err != nil {
496
510
logError ("%s" , err )
497
511
}
498
- <- deleteChannel
512
+ <- deleteChannel
499
513
}(filePath , deleteChannel , useTrash )
500
514
}
501
515
break
@@ -509,7 +523,7 @@ func processFileActions(fileActions []*FileAction, dryRun bool) error {
509
523
510
524
doneActions = append (doneActions , action )
511
525
}
512
-
526
+
513
527
deleteWaitGroup .Wait ()
514
528
515
529
// Conflict resolution:
@@ -630,7 +644,7 @@ func main() {
630
644
return
631
645
}
632
646
633
- filePaths , err := filePathsFromArgs (args )
647
+ filePaths , err := filePathsFromArgs (args , config_ . Bool ( "include_directories" ) )
634
648
635
649
if err != nil {
636
650
criticalError (err )
0 commit comments