-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
61 lines (53 loc) · 1.57 KB
/
Copy pathmain.go
File metadata and controls
61 lines (53 loc) · 1.57 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
)
var version = "dev"
func main() {
if len(os.Args) > 1 {
switch os.Args[1] {
case "--version", "-v":
fmt.Println("tkz " + version)
os.Exit(0)
case "--help", "-h":
printHelp()
os.Exit(0)
}
}
if err := os.MkdirAll(getConfigDir(), 0755); err != nil {
fmt.Fprintf(os.Stderr, "Failed to create config directory: %v\n", err)
os.Exit(1)
}
bwSession := os.Getenv("BW_SESSION")
os.Unsetenv("BW_SESSION")
p := tea.NewProgram(initialModel(bwSession), tea.WithAltScreen())
if _, err := p.Run(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}
func printHelp() {
fmt.Println("tkz - OAuth Token Manager")
fmt.Println()
fmt.Println("Manage OAuth clients and retrieve bearer tokens for development.")
fmt.Println("Secrets are fetched from Bitwarden at runtime, never stored locally.")
fmt.Println()
fmt.Println("Usage: tkz [flags]")
fmt.Println()
fmt.Println("Flags:")
fmt.Println(" --help, -h Show this help")
fmt.Println(" --version, -v Show version")
fmt.Println()
fmt.Println("Environment:")
fmt.Println(" BW_SESSION Bitwarden session key (optional, tkz prompts if needed)")
fmt.Println()
fmt.Println("Key Bindings:")
fmt.Println(" enter Get token for selected client")
fmt.Println(" a Add new OAuth client")
fmt.Println(" e Edit selected client")
fmt.Println(" d Delete selected client")
fmt.Println(" / Filter clients")
fmt.Println(" q Quit")
}