Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Commit

Permalink
add version
Browse files Browse the repository at this point in the history
  • Loading branch information
high-moctane committed Jan 6, 2020
1 parent 9bfb551 commit df9af57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import (
"strings"
)

// Version (semantic)
const Version = "0.0.1"

// environmental variable
const nextwordDataPath = "NEXTWORD_DATA_PATH"

// flags
var versionFlag = flag.Bool("v", false, "show version")
var dataPath = flag.String("data", os.Getenv(nextwordDataPath), "path to the data directory")
var candidateNum = flag.Int("candidate-num", 100, "max candidates number")
var helpFlag = flag.Bool("h", false, "show this message")
Expand All @@ -27,6 +31,12 @@ func main() {
func run() error {
flag.Parse()

// version
if *versionFlag {
showVersion()
return nil
}

// help
if *helpFlag {
showHelpMessage()
Expand Down Expand Up @@ -60,6 +70,10 @@ func run() error {
return nil
}

func showVersion() {
fmt.Fprintln(os.Stderr, fmt.Sprintf("nextword version %s", Version))
}

func showHelpMessage() {
fmt.Fprintln(os.Stderr, "Nextword prints the most likely English words that follow the stdin sentence.")
fmt.Fprintln(os.Stderr)
Expand Down
2 changes: 1 addition & 1 deletion nextword.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// ReadLineBufSize is buffer size for Nextword.ReadLine
var ReadLineBufSize = 1024 // 1024 is fast (?)
var ReadLineBufSize = 10000 // 10000 is the fastest value (?)

// NextwordParams is a Nextword parameter.
type NextwordParams struct {
Expand Down

0 comments on commit df9af57

Please sign in to comment.