Skip to content

Commit

Permalink
Add version command
Browse files Browse the repository at this point in the history
Signed-off-by: Takumi Yanagawa <yana@jp.ibm.com>
  • Loading branch information
yana1205 committed Dec 7, 2023
1 parent 4352401 commit 34d1ba2
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion cmd/c2pcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,36 @@ limitations under the License.
package main

import (
"fmt"
"os"

"github.com/IBM/compliance-to-policy/cmd/c2pcli/cmd"
"github.com/spf13/cobra"
)

var (
version = "none"
commit = "none"
date = "unknown"
)

func newVersionSubCommand() *cobra.Command {
command := &cobra.Command{
Use: "version",
Short: "Display version",
RunE: func(cmd *cobra.Command, args []string) error {
message := fmt.Sprintf("version: %s, commit: %s, date: %s", version, commit, date)
fmt.Fprintln(os.Stdout, message)
return nil
},
}
return command
}

func main() {
err := cmd.New().Execute()
command := cmd.New()
command.AddCommand(newVersionSubCommand())
err := command.Execute()
if err != nil {
os.Exit(1)
}
Expand Down

0 comments on commit 34d1ba2

Please sign in to comment.