Skip to content

Commit 84effeb

Browse files
feat: add init command
1 parent 1d11ac9 commit 84effeb

File tree

5 files changed

+648
-45
lines changed

5 files changed

+648
-45
lines changed

cmd/init.go

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,24 @@
11
/*
2-
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
2+
Copyright © 2023 TestCoders / DeTesters
33
44
*/
55
package cmd
66

77
import (
8-
"fmt"
9-
108
"github.com/spf13/cobra"
9+
"github.com/testcoders/detestcoder/internal/app"
1110
)
1211

1312
// initCmd represents the init command
1413
var initCmd = &cobra.Command{
1514
Use: "init",
16-
Short: "A brief description of your command",
17-
Long: `A longer description that spans multiple lines and likely contains examples
18-
and usage of using your command. For example:
19-
20-
Cobra is a CLI library for Go that empowers applications.
21-
This application is a tool to generate the needed files
22-
to quickly create a Cobra application.`,
15+
Short: "Initialize your 'detestcoder' setup",
16+
Long: "Use this command to generate a .detestcoder.yaml config file in your home directory.",
2317
Run: func(cmd *cobra.Command, args []string) {
24-
fmt.Println("init called")
18+
app.WriteConfig()
2519
},
2620
}
2721

2822
func init() {
2923
rootCmd.AddCommand(initCmd)
30-
31-
// Here you will define your flags and configuration settings.
32-
33-
// Cobra supports Persistent Flags which will work for this command
34-
// and all subcommands, e.g.:
35-
// initCmd.PersistentFlags().String("foo", "", "A help for foo")
36-
37-
// Cobra supports local flags which will only run when this command
38-
// is called directly, e.g.:
39-
// initCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
4024
}

cmd/root.go

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*
2-
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
2+
Copyright © 2023 TestCoders / DeTesters
33
44
*/
5+
56
package cmd
67

78
import (
@@ -10,21 +11,11 @@ import (
1011
"github.com/spf13/cobra"
1112
)
1213

13-
14-
1514
// rootCmd represents the base command when called without any subcommands
1615
var rootCmd = &cobra.Command{
1716
Use: "detestcoder",
18-
Short: "A brief description of your application",
19-
Long: `A longer description that spans multiple lines and likely contains
20-
examples and usage of using your application. For example:
21-
22-
Cobra is a CLI library for Go that empowers applications.
23-
This application is a tool to generate the needed files
24-
to quickly create a Cobra application.`,
25-
// Uncomment the following line if your bare application
26-
// has an action associated with it:
27-
// Run: func(cmd *cobra.Command, args []string) { },
17+
Short: "An AI driven tool for test automation",
18+
Long: `Use 'detestcoder' to automatically generate test code based on your input.`,
2819
}
2920

3021
// Execute adds all child commands to the root command and sets flags appropriately.
@@ -37,15 +28,5 @@ func Execute() {
3728
}
3829

3930
func init() {
40-
// Here you will define your flags and configuration settings.
41-
// Cobra supports persistent flags, which, if defined here,
42-
// will be global for your application.
43-
44-
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.detestcoder.yaml)")
45-
46-
// Cobra also supports local flags, which will only run
47-
// when this action is called directly.
4831
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
4932
}
50-
51-

go.mod

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,26 @@ module github.com/testcoders/detestcoder
33
go 1.18
44

55
require (
6+
github.com/spf13/cobra v1.7.0
7+
github.com/spf13/viper v1.15.0
8+
)
9+
10+
require (
11+
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
12+
github.com/fsnotify/fsnotify v1.6.0 // indirect
13+
github.com/hashicorp/hcl v1.0.0 // indirect
614
github.com/inconshreveable/mousetrap v1.1.0 // indirect
7-
github.com/spf13/cobra v1.7.0 // indirect
15+
github.com/magiconair/properties v1.8.7 // indirect
16+
github.com/manifoldco/promptui v0.9.0 // indirect
17+
github.com/mitchellh/mapstructure v1.5.0 // indirect
18+
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
19+
github.com/spf13/afero v1.9.3 // indirect
20+
github.com/spf13/cast v1.5.0 // indirect
21+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
822
github.com/spf13/pflag v1.0.5 // indirect
23+
github.com/subosito/gotenv v1.4.2 // indirect
24+
golang.org/x/sys v0.3.0 // indirect
25+
golang.org/x/text v0.5.0 // indirect
26+
gopkg.in/ini.v1 v1.67.0 // indirect
27+
gopkg.in/yaml.v3 v3.0.1 // indirect
928
)

0 commit comments

Comments
 (0)