Skip to content

Commit

Permalink
Add flag for printing current version
Browse files Browse the repository at this point in the history
  • Loading branch information
rxbn committed Feb 20, 2022
1 parent a83ff10 commit f93fda7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ A small CLI tool to generate TOTP (Time-based One-time Password) tokens.

```
-s, --secretkey string supply a valid TOTP secret key to generate a token from
-v, --version print version and exit
```
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@ package main
import (
"fmt"
"log"
"os"

flag "github.com/spf13/pflag"
"github.com/xlzd/gotp"
)

const version = "2.0.1"

func main() {
secretKey := flag.StringP("secretkey", "s", "", "supply a valid TOTP secret key to generate a token from")
printVersion := flag.BoolP("version", "v", false, "Print the current version and exit")
flag.Parse()

if *printVersion {
fmt.Println(version)
os.Exit(0)
}

if *secretKey == "" {
log.Fatal("secretkey cannot be empty")
}
Expand Down

0 comments on commit f93fda7

Please sign in to comment.