Skip to content

Commit

Permalink
Add version
Browse files Browse the repository at this point in the history
  • Loading branch information
revelaction committed Oct 9, 2023
1 parent c387696 commit bdb3952
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Options:
-o, --output OUTPUT The OUTPUT file to be imported by Anki
-p, --guid-prefix A prefix to build the guid of all notes note of INPUT
-t, --tag A Tag to all notes of INPUT. Can be repeated
--version The version
INPUT should be a valid markdown file with the following structure:
Expand Down
16 changes: 16 additions & 0 deletions cmd/mankidown/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Options:
-o, --output OUTPUT The OUTPUT file to be imported by Anki
-p, --guid-prefix A prefix to build the guid of all notes note of INPUT
-t, --tag A Tag to all notes of INPUT. Can be repeated
--version The version
INPUT should be a valid markdown file with the following structure:
Expand Down Expand Up @@ -70,14 +71,19 @@ func (f *multiFlag) Set(value string) error {
return nil
}

// Version can be set at link time
var Version string

func main() {

flag.Usage = func() { fmt.Fprintf(os.Stderr, "%s\n", usage) }

conf := new(mankidown.Config)
var outFlag, guidPrefix string
var tagFlags multiFlag
var versionFlag bool

flag.BoolVar(&versionFlag, "version", false, "print the version")
flag.StringVar(&outFlag, "o", "", "output to `FILE` (default stdout)")
flag.StringVar(&outFlag, "output", "", "output to `FILE` (default stdout)")
flag.StringVar(&conf.Deck, "d", "", "Export to the Anki Deck")
Expand All @@ -90,6 +96,16 @@ func main() {
flag.Var(&tagFlags, "tags", "Add tag")
flag.Parse()

if versionFlag {
if Version != "" {
fmt.Println(Version)
return
}
fmt.Println("(unknown)")
return
}


if flag.NArg() == 0 {
flag.Usage()
os.Exit(1)
Expand Down

0 comments on commit bdb3952

Please sign in to comment.