-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
68 lines (61 loc) · 1.51 KB
/
Copy pathmain.go
File metadata and controls
68 lines (61 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"os"
)
var version = "dev"
func main() {
if err := run(os.Args[1:]); err != nil {
fmt.Fprintln(os.Stderr, "Error:", err)
os.Exit(1)
}
}
func run(args []string) error {
if len(args) == 0 || args[0] == "--help" || args[0] == "help" {
printUsage()
return nil
}
switch args[0] {
case "version", "--version":
fmt.Println(version)
return nil
case "tui", "--tui":
return runTUI(os.Stdin, os.Stdout)
case "scan":
directory, format, err := directoryOptions(args[1:])
if err != nil {
return err
}
return scanDirectory(directory, format)
case "duplicates":
directory, format, err := directoryOptions(args[1:])
if err != nil {
return err
}
return findDuplicates(directory, format)
case "security":
return runSecurity(args[1:])
case "organize":
return runOrganization(args[1:])
case "trash":
return runTrash(args[1:])
case "undo":
return runUndo(args[1:])
default:
printUsage()
return fmt.Errorf("unknown command %q", args[0])
}
}
func printUsage() {
fmt.Println(`Download Inbox Cleaner
Usage:
cleaner scan [--dir DIRECTORY] [--format text|json]
cleaner duplicates [--dir DIRECTORY] [--format text|json]
cleaner security [av] [--dir DIRECTORY] [--format text|json]
cleaner organize [--apply --yes] [--dir DIRECTORY]
cleaner trash [--apply --yes] [--dir DIRECTORY] <file-name> [file-name...]
cleaner undo [--yes]
cleaner tui
cleaner version
Directories default to ~/Downloads. Commands that change files require both --apply and --yes.`)
}