From f8c4ddc388be78876e4eda26b76aaed5f2cfcac7 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 7 Sep 2020 11:59:41 -0400 Subject: [PATCH] Remove disabled force key/identity file stuff for now --- main.go | 9 --------- ui/ui.go | 50 +++++++++++++++++++++----------------------------- 2 files changed, 21 insertions(+), 38 deletions(-) diff --git a/main.go b/main.go index 8774a71..e2da65c 100644 --- a/main.go +++ b/main.go @@ -177,9 +177,6 @@ func executeArg(cmd *cobra.Command, arg string, w io.Writer) error { return fmt.Errorf("error parsing config: %v", err) } - // Config from flags - // cfg.IdentityFile = identityFile - // Log to file, if set if cfg.Logfile != "" { f, err := tea.LogToFile(cfg.Logfile, "glow") @@ -295,12 +292,6 @@ func init() { rootCmd.Flags().StringVarP(&style, "style", "s", "auto", "style name or JSON path") rootCmd.Flags().UintVarP(&width, "width", "w", 0, "word-wrap at width") - // For network-related operations, namely stashing and the TUI - /* - rootCmd.PersistentFlags().StringVarP(&identityFile, "identity", "i", "", "path to identity file (that is, an ssh private key)") - rootCmd.PersistentFlags().BoolVarP(&forceKey, "force-key", "f", false, "force the use of the SSH key on disk (that is, ignore ssh-agent)") - */ - // Stash stashCmd.PersistentFlags().StringVarP(&memo, "memo", "m", "", "memo/note for stashing") rootCmd.AddCommand(stashCmd) diff --git a/ui/ui.go b/ui/ui.go index 05151de..b17a9b6 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -32,8 +32,6 @@ var ( // Config contains configuration specified to the TUI. type Config struct { - IdentityFile string - // For debugging the UI Logfile string `env:"GLOW_UI_LOGFILE"` HighPerformancePager bool `env:"GLOW_UI_HIGH_PERFORMANCE_PAGER" default:"true"` @@ -170,7 +168,7 @@ func initialize(cfg Config, style string) func() (tea.Model, tea.Cmd) { return m, tea.Batch( findLocalFiles, - newCharmClient(&cfg.IdentityFile), + newCharmClient, spinner.Tick(m.stash.spinner), ) } @@ -302,7 +300,7 @@ func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) { case keygenSuccessMsg: // The keygen's done, so let's try initializing the charm client again m.keygenState = keygenFinished - cmds = append(cmds, newCharmClient(nil)) + cmds = append(cmds, newCharmClient) case newCharmClientMsg: m.cc = msg @@ -434,32 +432,26 @@ func findNextLocalFile(m model) tea.Cmd { } } -func newCharmClient(identityFile *string) tea.Cmd { - return func() tea.Msg { - cfg, err := charm.ConfigFromEnv() - if err != nil { - return errMsg{err} - } - - if identityFile != nil { - cfg.SSHKeyPath = *identityFile - } - - cc, err := charm.NewClient(cfg) - if err == charm.ErrMissingSSHAuth { - if debug { - log.Println("missing SSH auth:", err) - } - return sshAuthErrMsg{} - } else if err != nil { - if debug { - log.Println("error creating new charm client:", err) - } - return errMsg{err} - } - - return newCharmClientMsg(cc) +func newCharmClient() tea.Msg { + cfg, err := charm.ConfigFromEnv() + if err != nil { + return errMsg{err} } + + cc, err := charm.NewClient(cfg) + if err == charm.ErrMissingSSHAuth { + if debug { + log.Println("missing SSH auth:", err) + } + return sshAuthErrMsg{} + } else if err != nil { + if debug { + log.Println("error creating new charm client:", err) + } + return errMsg{err} + } + + return newCharmClientMsg(cc) } func loadStash(m stashModel) tea.Cmd {