package main
import (
+ "flag"
"fmt"
"io"
"log"
CleanupTmp = "tmp"
)
+var (
+ DryRun = flag.Bool("dry-run", false, "do no delete files during cleanup, just show them")
+)
+
func redoDirClean(root, what string) error {
root, err := filepath.Abs(root)
if err != nil {
case CleanupLog:
if strings.HasSuffix(fi.Name(), LogSuffix) {
fmt.Println(pth)
- if err = os.Remove(pth); err != nil {
- return err
+ if !*DryRun {
+ if err = os.Remove(pth); err != nil {
+ return err
+ }
}
}
case CleanupTmp:
if strings.HasPrefix(fi.Name(), TmpPrefix) {
fmt.Println(pth)
- if err = os.Remove(pth); err != nil {
- return err
+ if !*DryRun {
+ if err = os.Remove(pth); err != nil {
+ return err
+ }
}
}
default:
if fi.Name() == RedoDir {
if what == CleanupFull {
fmt.Println(pthRel)
- err = os.RemoveAll(pth)
+ if !*DryRun {
+ err = os.RemoveAll(pth)
+ }
} else {
err = redoDirClean(pth, what)
}
if (what == CleanupTmp || what == CleanupFull) &&
strings.HasPrefix(fi.Name(), TmpPrefix) {
fmt.Println(pthRel)
- if err = os.Remove(pth); err != nil {
- return err
+ if !*DryRun {
+ if err = os.Remove(pth); err != nil {
+ return err
+ }
}
}
}
)
const (
- Version = "1.0.0"
+ Version = "1.1.0"
Warranty = `This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
forcefully and *sequentially* build specified targets
* redo-always
always build current target. Unusable outside .do
-* redo-cleanup {full,log,tmp} [...]
+* redo-cleanup [-dry-run] {full,log,tmp} [...]
remove either all goredo's related temporary files, or kept stderr
logs, or everything (including .redo directories) related
* redo-dot target [...]