From f1da2dcb404a19a4980107b5f43a9a85fcff3e4e Mon Sep 17 00:00:00 2001 From: Miguel Mota Date: Thu, 27 Jun 2019 22:03:10 -0700 Subject: [PATCH] Hide open shortcut in statusbar if no open command found --- cointop/common/open/open.go | 5 +++++ cointop/statusbar.go | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cointop/common/open/open.go b/cointop/common/open/open.go index b8108e9..74f3efa 100644 --- a/cointop/common/open/open.go +++ b/cointop/common/open/open.go @@ -41,3 +41,8 @@ func URL(s string) error { } return nil } + +// CommandExists returns true if an 'open' command exists +func CommandExists() bool { + return openCmd != "" +} diff --git a/cointop/statusbar.go b/cointop/statusbar.go index 07314a1..79286cb 100644 --- a/cointop/statusbar.go +++ b/cointop/statusbar.go @@ -3,6 +3,7 @@ package cointop import ( "fmt" + "github.com/miguelmota/cointop/cointop/common/open" "github.com/miguelmota/cointop/cointop/common/pad" ) @@ -44,7 +45,14 @@ func (ct *Cointop) updateStatusbar(s string) error { return nil } -func (ct *Cointop) refreshRowLink() { +func (ct *Cointop) refreshRowLink() error { + var shortcut string + if !open.CommandExists() { + shortcut = "[O]Open " + } + url := ct.rowLinkShort() - ct.updateStatusbar(fmt.Sprintf("%sOpen %s", "[O]", url)) + ct.updateStatusbar(fmt.Sprintf("%s%s", shortcut, url)) + + return nil }