Skip to content

Commit

Permalink
Merge pull request #1348 from rsteube/add-melt
Browse files Browse the repository at this point in the history
added melt
  • Loading branch information
rsteube authored Oct 7, 2022
2 parents 39884ef + 1f0d5e2 commit 2b27852
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 2 deletions.
17 changes: 17 additions & 0 deletions completers/melt_completer/cmd/completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completionCmd = &cobra.Command{
Use: "completion",
Short: "Generate the autocompletion script for the specified shell",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completionCmd).Standalone()
rootCmd.AddCommand(completionCmd)
}
18 changes: 18 additions & 0 deletions completers/melt_completer/cmd/completion_bash.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completion_bashCmd = &cobra.Command{
Use: "bash",
Short: "Generate the autocompletion script for bash",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completion_bashCmd).Standalone()
completion_bashCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions")
completionCmd.AddCommand(completion_bashCmd)
}
18 changes: 18 additions & 0 deletions completers/melt_completer/cmd/completion_fish.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completion_fishCmd = &cobra.Command{
Use: "fish",
Short: "Generate the autocompletion script for fish",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completion_fishCmd).Standalone()
completion_fishCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions")
completionCmd.AddCommand(completion_fishCmd)
}
18 changes: 18 additions & 0 deletions completers/melt_completer/cmd/completion_powershell.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completion_powershellCmd = &cobra.Command{
Use: "powershell",
Short: "Generate the autocompletion script for powershell",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completion_powershellCmd).Standalone()
completion_powershellCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions")
completionCmd.AddCommand(completion_powershellCmd)
}
18 changes: 18 additions & 0 deletions completers/melt_completer/cmd/completion_zsh.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completion_zshCmd = &cobra.Command{
Use: "zsh",
Short: "Generate the autocompletion script for zsh",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completion_zshCmd).Standalone()
completion_zshCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions")
completionCmd.AddCommand(completion_zshCmd)
}
17 changes: 17 additions & 0 deletions completers/melt_completer/cmd/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var helpCmd = &cobra.Command{
Use: "help",
Short: "Help about any command",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(helpCmd).Standalone()
rootCmd.AddCommand(helpCmd)
}
24 changes: 24 additions & 0 deletions completers/melt_completer/cmd/restores.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var restoreCmd = &cobra.Command{
Use: "restore",
Short: "Recreate a key using the given seed phrase",
Run: func(cmd *cobra.Command, args []string) {},
}

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

restoreCmd.Flags().BoolP("help", "h", false, "help for restore")
restoreCmd.Flags().StringP("seed", "s", "", "Seed phrase (default \"-\")")
rootCmd.AddCommand(restoreCmd)

carapace.Gen(restoreCmd).PositionalCompletion(
carapace.ActionFiles(),
)
}
36 changes: 36 additions & 0 deletions completers/melt_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/net/ssh"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "melt",
Short: "melt generates a seed phrase from an SSH key",
Long: "https://github.com/charmbracelet/melt",
Run: func(cmd *cobra.Command, args []string) {},
}

func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()

rootCmd.PersistentFlags().BoolP("help", "h", false, "help for melt")
rootCmd.PersistentFlags().StringP("language", "l", "", "Language (default \"en\")")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"language": os.ActionLanguages(),
})

carapace.Gen(rootCmd).PositionalCompletion(
carapace.Batch(
carapace.ActionFiles(),
ssh.ActionPrivateKeys(),
).ToA(),
)
}
7 changes: 7 additions & 0 deletions completers/melt_completer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rsteube/carapace-bin/completers/melt_completer/cmd"

func main() {
cmd.Execute()
}
5 changes: 3 additions & 2 deletions pkg/actions/net/ssh/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/style"
)

type key struct {
Expand Down Expand Up @@ -59,7 +60,7 @@ func ActionPublicKeys() carapace.Action {
}
}
}
return carapace.ActionValuesDescribed(vals...)
return carapace.ActionValuesDescribed(vals...).StyleF(style.ForPath)
})
}

Expand Down Expand Up @@ -91,6 +92,6 @@ func ActionPrivateKeys() carapace.Action {
}
}
}
return carapace.ActionValuesDescribed(vals...)
return carapace.ActionValuesDescribed(vals...).StyleF(style.ForPath)
})
}

0 comments on commit 2b27852

Please sign in to comment.