package main import ( `context` `os` `sync` `github.com/hashicorp/vault-client-go` `github.com/jessevdk/go-flags` `github.com/pterm/pterm` `r00t2.io/goutils/logging` ) var ( logger logging.Logger args *Args = new(Args) parser *flags.Parser = flags.NewParser(args, flags.Default) ) var ( vc *vault.Client wg sync.WaitGroup cancelFunc context.CancelFunc ctx context.Context = context.Background() // keyed on vault TOTP key name otpCfgs map[string]*otpCfg = make(map[string]*otpCfg) // keyed on Vault TOTP key name kinfo map[string]map[string]any = make(map[string]map[string]any) ) var ( // This looks too goofy with the half-hour face. // It'd be better if I could do it in 15m increments, // but that doesn't exist in UTF-8 - half-hour-past is the closest fidelity we get... clocksFull []string = []string{ "🕛", "🕧", "🕐", "🕜", "🕑", "🕝", "🕒", "🕞", "🕓", "🕟", "🕔", "🕠", "🕕", "🕡", "🕖", "🕢", "🕗", "🕣", "🕘", "🕤", "🕙", "🕥", "🕚", "🕦", } // So do it hourly instead. clocksHourly []string = []string{ "🕛", "🕐", "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕗", "🕘", "🕙", "🕚", } // Level 1 "plain" (the clocks are level 0) plain1 []string = []string{ "◷", "◶", "◵", "◴", } plain2 []string = []string{ "⠈⠁", "⠈⠑", "⠈⠱", "⠈⡱", "⢀⡱", "⢄⡱", "⢄⡱", "⢆⡱", "⢎⡱", } // plain3 should restrict to pure ASCII plain3 []string = []string{ "|", "/", "-", "\\", "-", "|", } // indexed on level of plainness spinnerChars [][]string = [][]string{ clocksHourly, plain1, plain2, plain3, } // charSet is set to one of spinnerChars depending on args.GenArgs.Plain level. charSet []string /* Previously I was going to use https://pkg.go.dev/github.com/chelnak/ysmrr for this. Namely because I *thought* it was the only spinner lib that can do multiple spinners at once. (Even submitted a PR, https://github.com/chelnak/ysmrr/pull/88) HOWEVER, all spinners are synced to use the same animation... which means they all use the same frequency/rate of update. I want to sync it so the "animation" ends when the TOTP runs out (or thereabouts). pterm to the rescue. */ codeMulti pterm.MultiPrinter = pterm.MultiPrinter{ IsActive: false, Writer: os.Stdout, UpdateDelay: 0, } )