2 * Copyright (C) 2017 "IoT.bzh"
3 * Author Sebastien Douheret <sebastien@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
24 "github.com/iotbzh/xds-agent/lib/xaapiv1"
25 "github.com/urfave/cli"
28 func initCmdMisc(cmdDef *[]cli.Command) {
29 *cmdDef = append(*cmdDef, cli.Command{
32 Usage: "miscellaneous commands group",
33 Subcommands: []cli.Command{
36 Aliases: []string{"v"},
37 Usage: "Get version of XDS agent and XDS server",
42 Usage: "display verbose output",
50 func xdsVersion(ctx *cli.Context) error {
51 verbose := ctx.Bool("verbose")
54 ver := xaapiv1.XDSVersion{}
55 if err := XdsVersionGet(&ver); err != nil {
56 return cli.NewExitError(err.Error(), 1)
59 writer := NewTableWriter()
60 fmt.Fprintln(writer, "Agent:")
61 fmt.Fprintln(writer, " ID:\t", ver.Client.ID)
62 v := ver.Client.Version
64 v += " (" + ver.Client.VersionGitTag + ")"
66 fmt.Fprintln(writer, " Version:\t", v)
68 fmt.Fprintln(writer, " API Version:\t", ver.Client.APIVersion)
71 for _, svr := range ver.Server {
72 fmt.Fprintln(writer, "Server:")
73 fmt.Fprintln(writer, " ID:\t", svr.ID)
76 v += " (" + svr.VersionGitTag + ")"
78 fmt.Fprintln(writer, " Version:\t", v)
80 fmt.Fprintln(writer, " API Version:\t", svr.APIVersion)