Skip to content

Commit

Permalink
add version subcmd
Browse files Browse the repository at this point in the history
  • Loading branch information
laureanray committed Aug 16, 2023
1 parent 7963442 commit 18028c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 13 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
)

var version string

var rootCmd = &cobra.Command{
Use: "clibgen",
Short: "Library Genesis command line / terminal client",
Expand All @@ -14,6 +17,15 @@ Clibgen is a CLI application to search and download epubs, pdfs, from library ge
Useful if you are lazy to open up a browser to download e-books/resources.`,
}

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of Hugo",
Long: `All software has versions. This is Hugo's`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version)
},
}

func Execute() {
err := rootCmd.Execute()
if err != nil {
Expand All @@ -22,5 +34,5 @@ func Execute() {
}

func init() {
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
rootCmd.AddCommand(versionCmd)
}
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import "github.com/laureanray/clibgen/cmd"
import (
"github.com/laureanray/clibgen/cmd"
)

func main() {
cmd.Execute()
Expand Down

0 comments on commit 18028c0

Please sign in to comment.