11package yaakcli
22
33import (
4- "github.com/pterm/pterm"
5- "github.com/spf13/cobra"
64 "os"
75 "os/exec"
6+
7+ "github.com/pterm/pterm"
8+ "github.com/spf13/cobra"
89)
910
1011var generateCmd = & cobra.Command {
1112 Use : "generate" ,
1213 Short : `Generate a "Hello World" Yaak plugin` ,
1314 Run : func (cmd * cobra.Command , args []string ) {
14- defaultName := RandomName ()
15- defaultPath := "./" + defaultName
16-
17- _ = defaultPath
15+ pluginName , err := pterm .DefaultInteractiveTextInput .WithDefaultText ("Plugin name" ).WithDefaultValue (RandomName ()).Show ()
16+ CheckError (err )
1817
19- pluginDir , err := pterm .DefaultInteractiveTextInput .WithDefaultValue (defaultPath ).Show ()
18+ pluginDir , err := pterm .DefaultInteractiveTextInput .WithDefaultText ( "Plugin dir" ). WithDefaultValue ("./" + pluginName ).Show ()
2019 CheckError (err )
2120
2221 if fileExists (pluginDir ) {
@@ -29,10 +28,10 @@ var generateCmd = &cobra.Command{
2928 CheckError (os .MkdirAll (pluginDir , 0755 ))
3029
3130 // Copy static files
32- copyFile ("package.json" , pluginDir , defaultName )
33- copyFile ("tsconfig.json" , pluginDir , defaultName )
34- copyFile ("src/index.ts" , pluginDir , defaultName )
35- copyFile ("src/index.test.ts" , pluginDir , defaultName )
31+ copyFile ("package.json" , pluginDir , pluginName )
32+ copyFile ("tsconfig.json" , pluginDir , pluginName )
33+ copyFile ("src/index.ts" , pluginDir , pluginName )
34+ copyFile ("src/index.test.ts" , pluginDir , pluginName )
3635
3736 primary := pterm .NewStyle (pterm .FgLightWhite , pterm .BgMagenta , pterm .Bold )
3837
0 commit comments