mirror of
https://github.com/offen/docker-volume-backup.git
synced 2026-01-20 13:13:09 +01:00
* Add "show-config" subcommand * Add integration tests * Handle wrong additional args * Support "BackupFilenameExpand" option * Rename to print-config * Remove config nil check as it will never be nil * Rework print config to work with config.resolve() * Use defer unset() * Add warning about feature not being stable yet
35 lines
759 B
Go
35 lines
759 B
Go
// Copyright 2021-2022 - offen.software <hioffen@posteo.de>
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
)
|
|
|
|
func main() {
|
|
foreground := flag.Bool("foreground", false, "run the tool in the foreground")
|
|
profile := flag.String("profile", "", "collect runtime metrics and log them periodically on the given cron expression")
|
|
flag.Parse()
|
|
additionalArgs := flag.Args()
|
|
c := newCommand()
|
|
|
|
if len(additionalArgs) > 0 {
|
|
switch additionalArgs[0] {
|
|
case "print-config":
|
|
c.must(runPrintConfig())
|
|
return
|
|
default:
|
|
panic("unknown command: " + additionalArgs[0])
|
|
}
|
|
}
|
|
if *foreground {
|
|
opts := foregroundOpts{
|
|
profileCronExpression: *profile,
|
|
}
|
|
c.must(c.runInForeground(opts))
|
|
} else {
|
|
c.must(c.runAsCommand())
|
|
}
|
|
}
|