2025-04-16 19:25:21 -04:00
|
|
|
/*
|
2025-04-17 11:20:39 -04:00
|
|
|
Copyright © 2025 Jake jake.young.dev@gmail.com
|
2025-04-16 19:25:21 -04:00
|
|
|
*/
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
// viewCmd represents the view command
|
|
|
|
var viewCmd = &cobra.Command{
|
|
|
|
Use: "view <name>",
|
|
|
|
Example: "mctl view test",
|
|
|
|
Short: "View saved commands",
|
|
|
|
Long: `Load command using the supplied name and displays it in the terminal`,
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
fmt.Printf("\nCommand: %s\n", viper.Get(args[0]))
|
|
|
|
},
|
|
|
|
PreRunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
if len(args) == 0 {
|
|
|
|
return errors.New("name argument is required")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(viewCmd)
|
|
|
|
}
|