Skip to content

Commit

Permalink
Merge pull request #1639 from rsteube/remove-execute-funcs
Browse files Browse the repository at this point in the history
replace execute funcs with bridge action
  • Loading branch information
rsteube authored Apr 5, 2023
2 parents 4b69fb1 + 0f8fdc8 commit 7bc35d4
Show file tree
Hide file tree
Showing 26 changed files with 304 additions and 186 deletions.
5 changes: 0 additions & 5 deletions completers/aplay_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ func Execute() error {
return rootCmd.Execute()
}

func ExecuteArecord() error {
rootCmd.Use = "arecord"
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

Expand Down
27 changes: 19 additions & 8 deletions completers/arecord_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace-bin/completers/aplay_completer/cmd"
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

/**
Description for go:generate
Use: "arecord",
Short: "command-line sound recorder and player for ALSA soundcard driver",
Long: "https://linux.die.net/man/1/arecord",
*/
var rootCmd = &cobra.Command{
Use: "arecord",
Short: "command-line sound recorder and player for ALSA soundcard driver",
Long: "https://linux.die.net/man/1/arecord",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}

func Execute() error {
return cmd.ExecuteArecord()
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

carapace.Gen(rootCmd).PositionalAnyCompletion(
bridge.ActionCarapaceBin("aplay"),
)
}
5 changes: 0 additions & 5 deletions completers/brotli_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ func Execute() error {
return rootCmd.Execute()
}

func ExecuteUnbrotli() error {
rootCmd.Use = "unbrotli"
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

Expand Down
27 changes: 19 additions & 8 deletions completers/chromium_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace-bin/completers/google-chrome_completer/cmd"
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

/**
Description for go:generate
Use: "chromium",
Short: "chromium browser",
Long: "https://www.chromium.org/Home",
*/
var rootCmd = &cobra.Command{
Use: "chromium",
Short: "chromium browser",
Long: "https://www.chromium.org/Home",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}

func Execute() error {
return cmd.ExecuteAlias("chromium")
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

carapace.Gen(rootCmd).PositionalAnyCompletion(
bridge.ActionCarapaceBin("google-chrome"),
)
}
27 changes: 19 additions & 8 deletions completers/code-insiders_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace-bin/completers/code_completer/cmd"
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

/**
Description for go:generate
Use: "code-insiders",
Short: "Visual Studio Code Insiders",
Long: "https://code.visualstudio.com/insiders/",
*/
var rootCmd = &cobra.Command{
Use: "code-insiders",
Short: "Visual Studio Code Insiders",
Long: "https://code.visualstudio.com/insiders/",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}

func Execute() error {
return cmd.ExecuteInsiders()
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

carapace.Gen(rootCmd).PositionalAnyCompletion(
bridge.ActionCarapaceBin("code"),
)
}
5 changes: 0 additions & 5 deletions completers/code_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ func Execute() error {
return rootCmd.Execute()
}

func ExecuteInsiders() error {
rootCmd.Use = "code-insiders"
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

Expand Down
27 changes: 19 additions & 8 deletions completers/egrep_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace-bin/completers/grep_completer/cmd"
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

/**
Description for go:generate
Use: "egrep",
Short: "print lines that match patterns",
Long: "https://linux.die.net/man/1/grep",
*/
var rootCmd = &cobra.Command{
Use: "egrep",
Short: "print lines that match patterns",
Long: "https://linux.die.net/man/1/grep",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}

func Execute() error {
return cmd.ExecuteOverride("egrep")
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

carapace.Gen(rootCmd).PositionalAnyCompletion(
bridge.ActionCarapaceBin("grep"),
)
}
27 changes: 19 additions & 8 deletions completers/fgrep_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace-bin/completers/grep_completer/cmd"
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

/**
Description for go:generate
Use: "fgrep",
Short: "print lines that match patterns",
Long: "https://en.wikipedia.org/wiki/Grep",
*/
var rootCmd = &cobra.Command{
Use: "fgrep",
Short: "print lines that match patterns",
Long: "https://en.wikipedia.org/wiki/Grep",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}

func Execute() error {
return cmd.ExecuteOverride("fgrep")
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

carapace.Gen(rootCmd).PositionalAnyCompletion(
bridge.ActionCarapaceBin("grep"),
)
}
5 changes: 0 additions & 5 deletions completers/google-chrome_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ func Execute() error {
return rootCmd.Execute()
}

func ExecuteAlias(alias string) error {
rootCmd.Use = alias
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

Expand Down
6 changes: 0 additions & 6 deletions completers/grep_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ func Execute() error {
return rootCmd.Execute()
}

// ExecuteOverride overrides Use before execution
func ExecuteOverride(use string) error {
rootCmd.Use = use
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

Expand Down
12 changes: 0 additions & 12 deletions completers/halt_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ func Execute() error {
return rootCmd.Execute()
}

func ExecutePoweroff() error {
rootCmd.Use = "poweroff"
rootCmd.Short = "poweroff the machine"
return Execute()
}

func ExecuteReboot() error {
rootCmd.Use = "reboot"
rootCmd.Short = "reboot the machine"
return Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

Expand Down
5 changes: 0 additions & 5 deletions completers/helix_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ func Execute() error {
return rootCmd.Execute()
}

func ExecuteHx() error {
rootCmd.Use = "hx"
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

Expand Down
6 changes: 0 additions & 6 deletions completers/http_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ func Execute() error {
return rootCmd.Execute()
}

// ExecuteHttps replace Use with `https` before execution (https alias command for httpie)
func ExecuteHttps() error {
rootCmd.Use = "https" // TODO works for now
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

Expand Down
27 changes: 19 additions & 8 deletions completers/https_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace-bin/completers/http_completer/cmd"
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

/**
Description for go:generate
Use: "https",
Short: "command-line HTTP client for the API era",
Long: "https://httpie.io/",
*/
var rootCmd = &cobra.Command{
Use: "https",
Short: "command-line HTTP client for the API era",
Long: "https://httpie.io/",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}

func Execute() error {
return cmd.ExecuteHttps()
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

carapace.Gen(rootCmd).PositionalAnyCompletion(
bridge.ActionCarapaceBin("http"),
)
}
27 changes: 19 additions & 8 deletions completers/hx_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace-bin/completers/helix_completer/cmd"
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

/**
Description for go:generate
Use: "hx",
Short: "A post-modern text editor",
Long: "https://helix-editor.com/",
*/
var rootCmd = &cobra.Command{
Use: "hx",
Short: "A post-modern text editor",
Long: "https://helix-editor.com/",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}

func Execute() error {
return cmd.ExecuteHx()
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

carapace.Gen(rootCmd).PositionalAnyCompletion(
bridge.ActionCarapaceBin("helix"),
)
}
27 changes: 19 additions & 8 deletions completers/lzcat_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace-bin/completers/xz_completer/cmd"
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

/**
Description for go:generate
Use: "lzcat",
Short: "Compress or decompress .xz and .lzma files",
Long: "https://linux.die.net/man/1/xz",
*/
var rootCmd = &cobra.Command{
Use: "lzcat",
Short: "Compress or decompress .xz and .lzma files",
Long: "https://linux.die.net/man/1/xz",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}

func Execute() error {
return cmd.ExecuteAlias("lzcat")
return rootCmd.Execute()
}

func init() {
carapace.Gen(rootCmd).Standalone()

carapace.Gen(rootCmd).PositionalAnyCompletion(
bridge.ActionCarapaceBin("xz"),
)
}
Loading

0 comments on commit 7bc35d4

Please sign in to comment.