Commit b362c00

Karn Wong <karn@karnwong.me>
2024-01-09 02:46:43
refactor: move to generate command
1 parent 823862d
cmd/security/security.go → cmd/generate/generate.go
@@ -1,4 +1,4 @@
-package security
+package generate
 
 import (
 	"fmt"
@@ -7,9 +7,9 @@ import (
 )
 
 var Cmd = &cobra.Command{
-	Use:   "security",
-	Short: "Security tools",
-	Long:  `Security tools`,
+	Use:   "generate",
+	Short: "Generate stuff",
+	Long:  `Generate stuff`,
 	Run: func(cmd *cobra.Command, args []string) {
 		fmt.Println("Please specify subcommand")
 	},
cmd/security/security_generate_passphrase.go → cmd/generate/generate_passphrase.go
@@ -1,4 +1,4 @@
-package security
+package generate
 
 import (
 	"fmt"
@@ -24,7 +24,7 @@ func generatePassphrase() string {
 }
 
 var generatePassphraseCmd = &cobra.Command{
-	Use:   "generate-passphrase",
+	Use:   "passphrase",
 	Short: "Generate passphrase",
 	Long:  `Generate passphrase. Result is copied to clipboard.`,
 	Run: func(cmd *cobra.Command, args []string) {
cmd/security/security_generate_password.go → cmd/generate/generate_password.go
@@ -1,4 +1,4 @@
-package security
+package generate
 
 import (
 	"fmt"
@@ -22,7 +22,7 @@ func generatePassword() string {
 }
 
 var generatePasswordCmd = &cobra.Command{
-	Use:   "generate-password",
+	Use:   "password",
 	Short: "Generate password",
 	Long:  `Generate password. Result is copied to clipboard.`,
 	Run: func(cmd *cobra.Command, args []string) {
cmd/security/security_generate_ssh_key.go → cmd/generate/generate_ssh_key.go
@@ -1,4 +1,4 @@
-package security
+package generate
 
 import (
 	"crypto"
@@ -75,7 +75,7 @@ func generateSSHKeyEDSA(fileName string) {
 }
 
 var generateSSHKeyCmd = &cobra.Command{
-	Use:   "generate-ssh-key",
+	Use:   "ssh-key",
 	Short: "Create SSH key",
 	Long:  `Create SSH key`,
 	Run: func(cmd *cobra.Command, args []string) {
cmd/root.go
@@ -3,8 +3,8 @@ package cmd
 import (
 	"os"
 
+	"github.com/kahnwong/swissknife/cmd/generate"
 	"github.com/kahnwong/swissknife/cmd/get"
-	"github.com/kahnwong/swissknife/cmd/security"
 	"github.com/spf13/cobra"
 )
 
@@ -25,5 +25,5 @@ func Execute() {
 func init() {
 	rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
 	rootCmd.AddCommand(get.Cmd)
-	rootCmd.AddCommand(security.Cmd)
+	rootCmd.AddCommand(generate.Cmd)
 }