-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.go
More file actions
43 lines (36 loc) · 825 Bytes
/
main.go
File metadata and controls
43 lines (36 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"os"
"github.com/alecthomas/kong"
"github.com/lox/notion-cli/cmd"
"github.com/lox/notion-cli/internal/cli"
)
var version = "dev"
func main() {
if shouldPrintVersionAndExit(os.Args[1:]) {
println("notion-cli version " + version)
os.Exit(0)
}
c := &cmd.CLI{}
ctx := kong.Parse(c,
kong.Name("notion-cli"),
kong.Description("A CLI for Notion"),
kong.UsageOnError(),
kong.Vars{"version": version},
)
cli.SetAccessToken(c.Token)
err := ctx.Run(&cmd.Context{
Token: c.Token,
APIToken: c.APIToken,
APIBaseURL: c.APIBaseURL,
APINotionVersion: c.APINotionVersion,
})
ctx.FatalIfErrorf(err)
os.Exit(0)
}
func shouldPrintVersionAndExit(args []string) bool {
if len(args) != 1 {
return false
}
return args[0] == "--version" || args[0] == "-v"
}