from sublime_plugin import WindowCommand

from ..git_command import GitCommand
from ..runtime import enqueue_on_worker
from ...common import util
from ..ui_mixins.quick_panel import show_remote_panel


__all__ = (
    "gs_fetch",
)


class gs_fetch(WindowCommand, GitCommand):

    """
    Display a panel of all git remotes for active repository and
    do a `git fetch` asynchronously.
    """

    def run(self, remote=None):
        if remote:
            return enqueue_on_worker(self.do_fetch, remote)

        show_remote_panel(self.on_remote_selection, show_option_all=True, allow_direct=True)

    def on_remote_selection(self, remote):
        if remote == "<ALL>":
            enqueue_on_worker(self.do_fetch)
        else:
            enqueue_on_worker(self.do_fetch, remote)

    def do_fetch(self, remote=None):
        if remote is None:
            self.window.status_message("Start fetching all remotes...")
        else:
            self.window.status_message("Start fetching {}...".format(remote))

        self.fetch(remote)
        self.window.status_message("Fetch complete.")
        util.view.refresh_gitsavvy(self.window.active_view())

@@ -1,46 +1,4 @@
-from sublime_plugin import WindowCommand%0A%0A
 from
@@ -155,38 +155,331 @@
 nel%0A
-%0A%0A__all__ = (%0A    %22gs_fetch%22,%0A
+from GitSavvy.core.base_commands import GsWindowCommand%0A%0A%0A__all__ = (%0A    %22gs_fetch%22,%0A)%0A%0A%0AMYPY = False%0Aif MYPY:%0A    from GitSavvy.core.base_commands import Args, Kont%0A%0A%0Adef ask_for_remote(cmd, args, done):%0A    # type: (GsWindowCommand, Args, Kont) -%3E None%0A    show_remote_panel(done, allow_direct=True, show_option_all=True
 )%0A%0A%0A
@@ -493,16 +493,18 @@
 s_fetch(
+Gs
 WindowCo
@@ -523,17 +523,16 @@
 mmand):%0A
-%0A
     %22%22%22%0A
@@ -645,40 +645,24 @@
 %22%22%22%0A
-%0A
     def
- run(self, remote=None):
+aults = %7B
 %0A   
@@ -670,310 +670,97 @@
     
-if 
+%22
 remote
-:%0A            return enqueue_on_worker(self.do_fetch, remote)%0A%0A        show_remote_panel(self.on_remote_selection, show_option_all=True, allow_direct=True)%0A%0A    def on_remote_selection(self, remote):%0A        if remote == %22%3CALL%3E%22:%0A            enqueue_on_worker(self.do_fetch)%0A        else:%0A    
+%22: ask_for_remote%0A    %7D%0A%0A    def run(self, remote):%0A        # type: (str) -%3E None%0A
     
@@ -838,15 +838,40 @@
 mote
-=
+):%0A        # type: (str) -%3E 
 None
-):
 %0A   
@@ -879,25 +879,58 @@
     
-if remote is None
+fetch_all = remote == %22%3CALL%3E%22%0A        if fetch_all
 :%0A  
@@ -1111,16 +1111,39 @@
 f.fetch(
+None if fetch_all else 
 remote)%0A

Use input handlers in `fetch.py`