mirror of
https://github.com/Luzifer/duplicity-backup.git
synced 2024-12-20 18:41:21 +00:00
Added silent flag
This commit is contained in:
parent
30caf687f0
commit
be22033f83
1 changed files with 7 additions and 3 deletions
4
main.go
4
main.go
|
@ -25,6 +25,8 @@ var (
|
||||||
|
|
||||||
DryRun bool `flag:"dry-run,n" default:"false" description:"Do a test-run without changes"`
|
DryRun bool `flag:"dry-run,n" default:"false" description:"Do a test-run without changes"`
|
||||||
Debug bool `flag:"debug,d" default:"false" description:"Print duplicity commands to output"`
|
Debug bool `flag:"debug,d" default:"false" description:"Print duplicity commands to output"`
|
||||||
|
Silent bool `flag:"silent,s" default:"false" description:"Do not print to stdout, only write to logfile (for example usefull for crons)"`
|
||||||
|
|
||||||
VersionAndExit bool `flag:"version" default:"false" description:"Print version and exit"`
|
VersionAndExit bool `flag:"version" default:"false" description:"Print version and exit"`
|
||||||
}{}
|
}{}
|
||||||
|
|
||||||
|
@ -62,7 +64,9 @@ func logf(pattern string, fields ...interface{}) {
|
||||||
t := time.Now().Format("2006-01-02 15:04:05")
|
t := time.Now().Format("2006-01-02 15:04:05")
|
||||||
pattern = fmt.Sprintf("(%s) ", t) + pattern + "\n"
|
pattern = fmt.Sprintf("(%s) ", t) + pattern + "\n"
|
||||||
fmt.Fprintf(logFile, pattern, fields...)
|
fmt.Fprintf(logFile, pattern, fields...)
|
||||||
|
if !cfg.Silent {
|
||||||
fmt.Printf(pattern, fields...)
|
fmt.Printf(pattern, fields...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in a new issue