Repository: rsteube/carapace
Pull request #456 (2022-04-02 13:45:16)

moved shell specific code to subpackage


Patch:
diff --git a/carapace.go b/carapace.go
index 1e43743..9882ea5 100644
--- a/carapace.go
+++ b/carapace.go
@@ -9,20 +9,20 @@ import (
 	"os"
 	"strings"
 
-	"github.com/rsteube/carapace/internal/bash"
-	"github.com/rsteube/carapace/internal/bash_ble"
 	"github.com/rsteube/carapace/internal/common"
-	"github.com/rsteube/carapace/internal/elvish"
-	"github.com/rsteube/carapace/internal/export"
-	"github.com/rsteube/carapace/internal/fish"
-	"github.com/rsteube/carapace/internal/ion"
-	"github.com/rsteube/carapace/internal/nushell"
-	"github.com/rsteube/carapace/internal/oil"
-	"github.com/rsteube/carapace/internal/powershell"
-	"github.com/rsteube/carapace/internal/tcsh"
+	"github.com/rsteube/carapace/internal/shell/bash"
+	"github.com/rsteube/carapace/internal/shell/bash_ble"
+	"github.com/rsteube/carapace/internal/shell/elvish"
+	"github.com/rsteube/carapace/internal/shell/export"
+	"github.com/rsteube/carapace/internal/shell/fish"
+	"github.com/rsteube/carapace/internal/shell/ion"
+	"github.com/rsteube/carapace/internal/shell/nushell"
+	"github.com/rsteube/carapace/internal/shell/oil"
+	"github.com/rsteube/carapace/internal/shell/powershell"
+	"github.com/rsteube/carapace/internal/shell/tcsh"
+	"github.com/rsteube/carapace/internal/shell/xonsh"
+	"github.com/rsteube/carapace/internal/shell/zsh"
 	"github.com/rsteube/carapace/internal/uid"
-	"github.com/rsteube/carapace/internal/xonsh"
-	"github.com/rsteube/carapace/internal/zsh"
 	"github.com/rsteube/carapace/pkg/ps"
 	"github.com/spf13/cobra"
 	"github.com/spf13/pflag"
diff --git a/defaultActions.go b/defaultActions.go
index 742776a..762ddb7 100644
--- a/defaultActions.go
+++ b/defaultActions.go
@@ -12,7 +12,7 @@ import (
 	exec "golang.org/x/sys/execabs"
 
 	"github.com/rsteube/carapace/internal/common"
-	"github.com/rsteube/carapace/internal/export"
+	"github.com/rsteube/carapace/internal/shell/export"
 	"github.com/rsteube/carapace/pkg/style"
 	"github.com/spf13/cobra"
 	"github.com/spf13/pflag"
diff --git a/internal/bash/action.go b/internal/shell/bash/action.go
similarity index 100%
rename from internal/bash/action.go
rename to internal/shell/bash/action.go
diff --git a/internal/bash/snippet.go b/internal/shell/bash/snippet.go
similarity index 100%
rename from internal/bash/snippet.go
rename to internal/shell/bash/snippet.go
diff --git a/internal/bash_ble/action.go b/internal/shell/bash_ble/action.go
similarity index 100%
rename from internal/bash_ble/action.go
rename to internal/shell/bash_ble/action.go
diff --git a/internal/bash_ble/snippet.go b/internal/shell/bash_ble/snippet.go
similarity index 95%
rename from internal/bash_ble/snippet.go
rename to internal/shell/bash_ble/snippet.go
index f055a84..eb88b4c 100644
--- a/internal/bash_ble/snippet.go
+++ b/internal/shell/bash_ble/snippet.go
@@ -5,7 +5,7 @@ import (
 	"fmt"
 	"regexp"
 
-	"github.com/rsteube/carapace/internal/bash"
+	"github.com/rsteube/carapace/internal/shell/bash"
 	"github.com/rsteube/carapace/internal/uid"
 	"github.com/spf13/cobra"
 )
diff --git a/internal/elvish/action.go b/internal/shell/elvish/action.go
similarity index 100%
rename from internal/elvish/action.go
rename to internal/shell/elvish/action.go
diff --git a/internal/elvish/snippet.go b/internal/shell/elvish/snippet.go
similarity index 100%
rename from internal/elvish/snippet.go
rename to internal/shell/elvish/snippet.go
diff --git a/internal/export/action.go b/internal/shell/export/action.go
similarity index 100%
rename from internal/export/action.go
rename to internal/shell/export/action.go
diff --git a/internal/export/snippet.go b/internal/shell/export/snippet.go
similarity index 100%
rename from internal/export/snippet.go
rename to internal/shell/export/snippet.go
diff --git a/internal/fish/action.go b/internal/shell/fish/action.go
similarity index 100%
rename from internal/fish/action.go
rename to internal/shell/fish/action.go
diff --git a/internal/fish/snippet.go b/internal/shell/fish/snippet.go
similarity index 100%
rename from internal/fish/snippet.go
rename to internal/shell/fish/snippet.go
diff --git a/internal/ion/action.go b/internal/shell/ion/action.go
similarity index 100%
rename from internal/ion/action.go
rename to internal/shell/ion/action.go
diff --git a/internal/ion/snippet.go b/internal/shell/ion/snippet.go
similarity index 100%
rename from internal/ion/snippet.go
rename to internal/shell/ion/snippet.go
diff --git a/internal/nushell/action.go b/internal/shell/nushell/action.go
similarity index 100%
rename from internal/nushell/action.go
rename to internal/shell/nushell/action.go
diff --git a/internal/nushell/snippet.go b/internal/shell/nushell/snippet.go
similarity index 100%
rename from internal/nushell/snippet.go
rename to internal/shell/nushell/snippet.go
diff --git a/internal/oil/action.go b/internal/shell/oil/action.go
similarity index 100%
rename from internal/oil/action.go
rename to internal/shell/oil/action.go
diff --git a/internal/oil/snippet.go b/internal/shell/oil/snippet.go
similarity index 100%
rename from internal/oil/snippet.go
rename to internal/shell/oil/snippet.go
diff --git a/internal/powershell/action.go b/internal/shell/powershell/action.go
similarity index 100%
rename from internal/powershell/action.go
rename to internal/shell/powershell/action.go
diff --git a/internal/powershell/snippet.go b/internal/shell/powershell/snippet.go
similarity index 100%
rename from internal/powershell/snippet.go
rename to internal/shell/powershell/snippet.go
diff --git a/internal/tcsh/action.go b/internal/shell/tcsh/action.go
similarity index 100%
rename from internal/tcsh/action.go
rename to internal/shell/tcsh/action.go
diff --git a/internal/tcsh/snippet.go b/internal/shell/tcsh/snippet.go
similarity index 100%
rename from internal/tcsh/snippet.go
rename to internal/shell/tcsh/snippet.go
diff --git a/internal/xonsh/action.go b/internal/shell/xonsh/action.go
similarity index 100%
rename from internal/xonsh/action.go
rename to internal/shell/xonsh/action.go
diff --git a/internal/xonsh/snippet.go b/internal/shell/xonsh/snippet.go
similarity index 100%
rename from internal/xonsh/snippet.go
rename to internal/shell/xonsh/snippet.go
diff --git a/internal/zsh/action.go b/internal/shell/zsh/action.go
similarity index 100%
rename from internal/zsh/action.go
rename to internal/shell/zsh/action.go
diff --git a/internal/zsh/snippet.go b/internal/shell/zsh/snippet.go
similarity index 100%
rename from internal/zsh/snippet.go
rename to internal/shell/zsh/snippet.go
diff --git a/invokedAction.go b/invokedAction.go
index a762029..c5d7e88 100644
--- a/invokedAction.go
+++ b/invokedAction.go
@@ -3,19 +3,19 @@ package carapace
 import (
 	"strings"
 
-	"github.com/rsteube/carapace/internal/bash"
-	"github.com/rsteube/carapace/internal/bash_ble"
 	"github.com/rsteube/carapace/internal/common"
-	"github.com/rsteube/carapace/internal/elvish"
-	"github.com/rsteube/carapace/internal/export"
-	"github.com/rsteube/carapace/internal/fish"
-	"github.com/rsteube/carapace/internal/ion"
-	"github.com/rsteube/carapace/internal/nushell"
-	"github.com/rsteube/carapace/internal/oil"
-	"github.com/rsteube/carapace/internal/powershell"
-	"github.com/rsteube/carapace/internal/tcsh"
-	"github.com/rsteube/carapace/internal/xonsh"
-	"github.com/rsteube/carapace/internal/zsh"
+	"github.com/rsteube/carapace/internal/shell/bash"
+	"github.com/rsteube/carapace/internal/shell/bash_ble"
+	"github.com/rsteube/carapace/internal/shell/elvish"
+	"github.com/rsteube/carapace/internal/shell/export"
+	"github.com/rsteube/carapace/internal/shell/fish"
+	"github.com/rsteube/carapace/internal/shell/ion"
+	"github.com/rsteube/carapace/internal/shell/nushell"
+	"github.com/rsteube/carapace/internal/shell/oil"
+	"github.com/rsteube/carapace/internal/shell/powershell"
+	"github.com/rsteube/carapace/internal/shell/tcsh"
+	"github.com/rsteube/carapace/internal/shell/xonsh"
+	"github.com/rsteube/carapace/internal/shell/zsh"
 )
 
 // InvokedAction is a logical alias for an Action whose (nested) callback was invoked


Test patch:
diff --git a/action_test.go b/action_test.go
index 873522d..ae443f7 100644
--- a/action_test.go
+++ b/action_test.go
@@ -150,7 +150,7 @@ func TestActionFilesChdir(t *testing.T) {
 
 	assertEqual(t,
 		ActionValues("action.go", "snippet.go").noSpace(true).Invoke(Context{}).Prefix("elvish/"),
-		ActionFiles().Chdir("internal").Invoke(Context{CallbackValue: "elvish/"}),
+		ActionFiles().Chdir("internal/shell").Invoke(Context{CallbackValue: "elvish/"}),
 	)
 
 	if newWd, _ := os.Getwd(); oldWd != newWd {