mirror of
https://github.com/restic/rest-server.git
synced 2026-09-26 14:01:21 -07:00
Use Cobra for showing the version
This commit is contained in:
+2
-10
@@ -21,8 +21,7 @@ var cmdRoot = &cobra.Command{
|
|||||||
SilenceErrors: true,
|
SilenceErrors: true,
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
RunE: runRoot,
|
RunE: runRoot,
|
||||||
// Use this instead of other --version code when the Cobra dependency can be updated.
|
Version: fmt.Sprintf("rest-server %s compiled with %v on %v/%v\n", version, runtime.Version(), runtime.GOOS, runtime.GOARCH),
|
||||||
//Version: fmt.Sprintf("rest-server %s compiled with %v on %v/%v\n", version, runtime.Version(), runtime.GOOS, runtime.GOARCH),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var server = restserver.Server{
|
var server = restserver.Server{
|
||||||
@@ -31,8 +30,7 @@ var server = restserver.Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
showVersion bool
|
cpuProfile string
|
||||||
cpuProfile string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -51,7 +49,6 @@ func init() {
|
|||||||
flags.BoolVar(&server.PrivateRepos, "private-repos", server.PrivateRepos, "users can only access their private repo")
|
flags.BoolVar(&server.PrivateRepos, "private-repos", server.PrivateRepos, "users can only access their private repo")
|
||||||
flags.BoolVar(&server.Prometheus, "prometheus", server.Prometheus, "enable Prometheus metrics")
|
flags.BoolVar(&server.Prometheus, "prometheus", server.Prometheus, "enable Prometheus metrics")
|
||||||
flags.BoolVar(&server.Prometheus, "prometheus-no-auth", server.PrometheusNoAuth, "disable auth for Prometheus /metrics endpoint")
|
flags.BoolVar(&server.Prometheus, "prometheus-no-auth", server.PrometheusNoAuth, "disable auth for Prometheus /metrics endpoint")
|
||||||
flags.BoolVarP(&showVersion, "version", "V", showVersion, "output version and exit")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var version = "0.10.0-dev"
|
var version = "0.10.0-dev"
|
||||||
@@ -77,11 +74,6 @@ func tlsSettings() (bool, string, string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runRoot(cmd *cobra.Command, args []string) error {
|
func runRoot(cmd *cobra.Command, args []string) error {
|
||||||
if showVersion {
|
|
||||||
fmt.Printf("rest-server %s compiled with %v on %v/%v\n", version, runtime.Version(), runtime.GOOS, runtime.GOARCH)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
|
|
||||||
log.Printf("Data directory: %s", server.Path)
|
log.Printf("Data directory: %s", server.Path)
|
||||||
|
|||||||
Reference in New Issue
Block a user