Skip to content

Commit

Permalink
feat: add --version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
DeeStarks committed Aug 13, 2022
1 parent 5ba82cd commit 771520d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ var (
Short: "Conoid is a reverse proxy server that can also expose your localhost on the internet",
Long: "CONOID:\nA simple HTTP server that can be used to serve static files. \nIt also provides TCP tunnelling through localtunnel to bypass a firewall or NAT,\nenabling local development servers be exposed to the internet.",
Run: func(cmd *cobra.Command, args []string) {
flags := cmd.Flags()

// Show version
if f, _ := flags.GetBool("version"); f {
fmt.Println(config.CURRENT_VERSION)
return
}

// Connect to the default db
defaultDB, err := sql.Open("sqlite3", config.DEFAULT_DB)
if err != nil {
Expand Down Expand Up @@ -78,5 +86,10 @@ var (
)

func Execute() {
// Version
rootCmd.PersistentFlags().BoolP("version", "v", false, "Show version")

// Execute
rootCmd.Execute()

}
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
)

const (
// App info
CURRENT_VERSION = "v0.0.1"

// Network
TCP_PORT = 5000
MAX_CONN_COUNT = 100
Expand Down

0 comments on commit 771520d

Please sign in to comment.