Skip to content

Commit 0535c27

Browse files
Showing messages before performing plugin action
1 parent 719aafb commit 0535c27

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

internal/action/command.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,29 @@ func (h *BufPane) PluginCmd(args []string) {
110110
return
111111
}
112112

113+
switch args[0] {
114+
case "install":
115+
InfoBar.Message("Downloading plugin, please wait...")
116+
case "remove":
117+
case "update":
118+
InfoBar.Message("Updating plugins, please wait...")
119+
case "available":
120+
InfoBar.Message("Fetching plugins, please wait...")
121+
case "list":
122+
case "search":
123+
InfoBar.Message("Fetching plugins, please wait...")
124+
default:
125+
InfoBar.Error("Invalid plugin command:", args[0])
126+
}
127+
128+
// NOTE: Display the message in info bar immediately before we get hang in PluginCommand()
129+
// Ideally we should lock it but it seems like main func in micro.go is constantly locking it
130+
// Locking it here will cause a deadlock
131+
// screen.Lock()
132+
InfoBar.Display()
133+
screen.Show()
134+
// screen.Unlock()
135+
113136
if h.Buf.Type != buffer.BTLog {
114137
h.OpenLogBuf()
115138
}

internal/config/plugin_installer.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (pc PluginChannels) Fetch(out io.Writer) PluginPackages {
130130

131131
// Fetch retrieves all available PluginPackages from the given channel
132132
func (pc PluginChannel) Fetch(out io.Writer) PluginPackages {
133-
client := http.Client {
133+
client := http.Client{
134134
Timeout: 30 * time.Second,
135135
}
136136
resp, err := client.Get(string(pc))
@@ -153,7 +153,7 @@ func (pc PluginChannel) Fetch(out io.Writer) PluginPackages {
153153

154154
// Fetch retrieves all available PluginPackages from the given repository
155155
func (pr PluginRepository) Fetch(out io.Writer) PluginPackages {
156-
client := http.Client {
156+
client := http.Client{
157157
Timeout: 30 * time.Second,
158158
}
159159
resp, err := client.Get(string(pr))
@@ -412,7 +412,7 @@ func GetInstalledPluginVersion(name string) string {
412412
// DownloadAndInstall downloads and installs the given plugin and version
413413
func (pv *PluginVersion) DownloadAndInstall(out io.Writer) error {
414414
fmt.Fprintf(out, "Downloading %q (%s) from %q\n", pv.pack.Name, pv.Version, pv.Url)
415-
client := http.Client {
415+
client := http.Client{
416416
Timeout: 30 * time.Second,
417417
}
418418
resp, err := client.Get(pv.Url)
@@ -664,6 +664,7 @@ func UpdatePlugins(out io.Writer, plugins []string) {
664664
func PluginCommand(out io.Writer, cmd string, args []string) {
665665
switch cmd {
666666
case "install":
667+
fmt.Fprintln(out, "Downloading plugin, please wait...")
667668
installedVersions := GetInstalledVersions(false)
668669
for _, plugin := range args {
669670
pp := GetAllPluginPackages(out).Get(plugin)
@@ -712,6 +713,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) {
712713
fmt.Fprintln(out, "No plugins removed")
713714
}
714715
case "update":
716+
fmt.Fprintln(out, "Updating plugins, please wait...")
715717
UpdatePlugins(out, args)
716718
case "list":
717719
plugins := GetInstalledVersions(false)
@@ -726,6 +728,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) {
726728
}
727729
}
728730
case "search":
731+
fmt.Fprintln(out, "Fetching plugins, please wait...")
729732
plugins := SearchPlugin(out, args)
730733
fmt.Fprintln(out, len(plugins), "plugins found")
731734
for _, p := range plugins {
@@ -734,6 +737,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) {
734737
}
735738
fmt.Fprintln(out, "----------------")
736739
case "available":
740+
fmt.Fprintln(out, "Fetching plugins, please wait...")
737741
packages := GetAllPluginPackages(out)
738742
fmt.Fprintln(out, "Available Plugins:")
739743
for _, pkg := range packages {

internal/screen/screen.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ func UnregisterRawSeq(r string) {
152152
if Screen != nil {
153153
Screen.UnregisterRawSeq(r)
154154
}
155+
156+
func Show() {
157+
Screen.Show()
155158
}
156159

157160
// TempFini shuts the screen down temporarily

0 commit comments

Comments
 (0)