cli: Add empty neofs-cli app structure
In the following release `neofs-cli` will be used to directly manage NeoFS Node. All required definitions and interfaces are also moving from `neofs-api` to `neofs-node` repository, so it's more convinient to have `neofs-cli` here. Signed-off-by: Stanislav Bogatyrev <stanislav@nspcc.ru>
This commit is contained in:
parent
f23d8a5f4a
commit
246a15de35
15 changed files with 423 additions and 6 deletions
47
cmd/neofs-cli/modules/version.go
Normal file
47
cmd/neofs-cli/modules/version.go
Normal file
|
@ -0,0 +1,47 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/nspcc-dev/neofs-node/misc"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
// versionCmd represents the version command
|
||||
versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print version and exit",
|
||||
Run: versionRun,
|
||||
}
|
||||
)
|
||||
|
||||
var flagJSON bool
|
||||
|
||||
type VersionInfo struct {
|
||||
Version string `json:"Version,omitempty"`
|
||||
Build string `json:"Build,omitempty"`
|
||||
Debug string `json:"Debug,omitempty"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
versionCmd.Flags().BoolVarP(&flagJSON, "json", "j", false, "Print version information in JSON")
|
||||
}
|
||||
|
||||
func versionRun(cmd *cobra.Command, args []string) {
|
||||
|
||||
versionInfo := VersionInfo{Version: misc.Version, Build: misc.Build, Debug: misc.Debug}
|
||||
|
||||
if flagJSON {
|
||||
bytes, _ := json.Marshal(versionInfo)
|
||||
fmt.Printf("%s", string(bytes)+"\n")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Version: %s \nBuild: %s \nDebug: %s\n",
|
||||
versionInfo.Version,
|
||||
versionInfo.Build,
|
||||
versionInfo.Debug)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue