mirror of
https://github.com/ferdzo/fs.git
synced 2026-04-05 08:26:28 +00:00
Initial FS CLI
This commit is contained in:
36
cmd/root.go
Normal file
36
cmd/root.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newRootCommand(build BuildInfo) *cobra.Command {
|
||||
root := &cobra.Command{
|
||||
Use: "fs",
|
||||
Short: "fs object storage server and admin CLI",
|
||||
SilenceUsage: true,
|
||||
SilenceErrors: true,
|
||||
Version: build.Version,
|
||||
}
|
||||
|
||||
root.SetVersionTemplate(versionTemplate(build))
|
||||
root.AddCommand(newServerCommand())
|
||||
root.AddCommand(newAdminCommand(build))
|
||||
root.AddCommand(&cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print build and runtime version information",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
_, err := fmt.Fprintf(cmd.OutOrStdout(), "version=%s commit=%s date=%s go=%s\n", build.Version, build.Commit, build.Date, runtime.Version())
|
||||
return err
|
||||
},
|
||||
})
|
||||
|
||||
return root
|
||||
}
|
||||
|
||||
func versionTemplate(build BuildInfo) string {
|
||||
return fmt.Sprintf("version=%s commit=%s date=%s\n", build.Version, build.Commit, build.Date)
|
||||
}
|
||||
Reference in New Issue
Block a user