diff --git a/README.md b/README.md
index e2c971f..7fe1a0b 100644
--- a/README.md
+++ b/README.md
@@ -70,6 +70,7 @@ Options:
--permanent delete a file permanently
-d/--directory show path to the data dir
-t/--set-dir
set the data dir and continue
+ -q/--quiet enable quiet mode
--disable-copy if files are on a different fs, don't rename by copy
-h/--help print this help message
-v/--version print Rem version
diff --git a/go.sum b/go.sum
index b219558..0782fbc 100644
--- a/go.sum
+++ b/go.sum
@@ -1,31 +1,20 @@
-github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
-github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
-github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
-github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
-github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
-github.com/otiai10/copy v1.5.0 h1:SoXDGnlTUZoqB/wSuj/Y5L6T5i6iN4YRAcMCd+JnLNU=
-github.com/otiai10/copy v1.5.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E=
github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE=
github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
-github.com/otiai10/mint v1.3.2 h1:VYWnrP5fXmz1MXvjuUvcBrXSjGE6xjON+axB/UrpO3E=
-github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI=
github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY=
-golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
diff --git a/rem.go b/rem.go
index 41f16af..92ee0a0 100644
--- a/rem.go
+++ b/rem.go
@@ -28,6 +28,7 @@ Options:
--permanent delete a file permanently
-d/--directory show path to the data dir
-t/--set-dir set the data dir and continue
+ -q/--quiet enable quiet mode
--disable-copy if files are on a different fs, don't rename by copy
-h/--help print this help message
-v/--version print Rem version`
@@ -35,7 +36,8 @@ Options:
logFileName = ".trash.log"
logFile map[string]string
renameByCopyIsAllowed = true
- //logSeparator = "\t==>\t"
+
+ quietMode = false
)
// TODO: Multiple Rem instances could clobber log file. Fix using either file locks or tcp port locks.
@@ -84,6 +86,13 @@ func main() {
return
}
+ if hasOption, i := argsHaveOption("quiet", "q"); hasOption {
+ quietMode = true
+ os.Args = removeElemFromSlice(os.Args, i)
+ main()
+ return
+ }
+
if hasOption, _ := argsHaveOption("directory", "d"); hasOption {
fmt.Println(dataDir)
return
@@ -144,7 +153,7 @@ func restore(path string) {
}
delete(logFile, absPath)
setLogFile(logFile) // we deleted an entry so save the edited logFile
- fmt.Println(color.YellowString(path) + " restored")
+ printIfNotQuiet(color.YellowString(path) + " restored")
}
func trashFile(path string) {
@@ -177,7 +186,7 @@ func trashFile(path string) {
setLogFile(m)
// if we've reached here, trashing is complete and successful
// TODO: Print with quotes only if it contains spaces
- fmt.Println("Trashed " + color.YellowString(path) + "\nUndo using " + color.YellowString("rem --undo \""+path+"\""))
+ printIfNotQuiet("Trashed " + color.YellowString(path) + "\nUndo using " + color.YellowString("rem --undo \""+path+"\""))
}
func renameByCopyAllowed(src, dst string) error {
@@ -216,7 +225,7 @@ func getTimestampedPath(path string, existsFunc func(string) bool) string {
}
}
if i != 0 {
- fmt.Println("To avoid conflicts, " + color.YellowString(oldPath) + " will now be called " + color.YellowString(path))
+ printIfNotQuiet("To avoid conflicts, " + color.YellowString(oldPath) + " will now be called " + color.YellowString(path))
}
return path
}
@@ -383,3 +392,9 @@ func printFormattedList(a []string) {
fmt.Println(color.CyanString(strconv.Itoa(i+1)+":"), elem)
}
}
+
+func printIfNotQuiet(a ...interface{}) {
+ if !quietMode {
+ fmt.Println(a...)
+ }
+}