@@ -28,11 +28,14 @@ func NewConfigCmd() *cobra.Command {
2828
2929// NewConfigInitCmd initializes the config file
3030func NewConfigInitCmd () * cobra.Command {
31+ var force bool
32+
3133 cmd := & cobra.Command {
3234 Use : "init" ,
3335 Short : "Initialize configuration file" ,
3436 Long : "Create a new configuration file with default values at ~/.goo/config.yaml" ,
35- Example : ` goo config init` ,
37+ Example : ` goo config init
38+ goo config init --force # Overwrite existing config` ,
3639 RunE : func (cmd * cobra.Command , args []string ) error {
3740 configPath , err := config .GetConfigPath ()
3841 if err != nil {
@@ -41,23 +44,71 @@ func NewConfigInitCmd() *cobra.Command {
4144
4245 // Check if config already exists
4346 if _ , err := os .Stat (configPath ); err == nil {
44- return fmt .Errorf ("config file already exists at %s" , configPath )
47+ if ! force {
48+ return fmt .Errorf ("config file already exists at %s (use --force to overwrite)" , configPath )
49+ }
50+ utils .PrintWarning ("Overwriting existing configuration..." )
4551 }
4652
53+ reader := bufio .NewReader (os .Stdin )
54+
4755 // Create config with default values
4856 cfg := config .DefaultConfig ()
4957
50- // Ask for Google API key (optional)
5158 fmt .Println ()
52- fmt .Println ("🔍 AI-Powered Proposal Configuration (Optional) " )
53- fmt .Println ("═══════════════════════════════════════════════ " )
59+ fmt .Println ("🔧 GOO CLI Configuration" )
60+ fmt .Println ("═══════════════════════════" )
5461 fmt .Println ()
55- fmt .Println ("The CLI can use Google Gemini AI to automatically research and propose values." )
56- fmt .Println ("This feature requires a free Google API key." )
62+
63+ // 1. Ask for key name
64+ fmt .Print ("Enter your gnokey name (default: test): " )
65+ keyName , _ := reader .ReadString ('\n' )
66+ keyName = strings .TrimSpace (keyName )
67+ if keyName != "" {
68+ cfg .KeyName = keyName
69+ }
70+
71+ // 2. Ask for network type
72+ fmt .Println ()
73+ fmt .Println ("Select network:" )
74+ fmt .Println (" 1. Development (local dev network)" )
75+ fmt .Println (" 2. Custom (specify chain ID and remote)" )
76+ fmt .Print ("Choice [1/2] (default: 1): " )
77+
78+ choice , _ := reader .ReadString ('\n' )
79+ choice = strings .TrimSpace (choice )
80+
81+ if choice == "2" {
82+ // Custom network
83+ fmt .Println ()
84+ fmt .Print ("Enter Chain ID: " )
85+ chainID , _ := reader .ReadString ('\n' )
86+ chainID = strings .TrimSpace (chainID )
87+ if chainID != "" {
88+ cfg .ChainID = chainID
89+ }
90+
91+ fmt .Print ("Enter Remote URL: " )
92+ remote , _ := reader .ReadString ('\n' )
93+ remote = strings .TrimSpace (remote )
94+ if remote != "" {
95+ cfg .Remote = remote
96+ }
97+ } else {
98+ // Dev network (default)
99+ cfg .ChainID = "dev"
100+ cfg .Remote = "tcp://127.0.0.1:26657"
101+ utils .PrintInfo ("Using dev network (chain_id: dev, remote: tcp://127.0.0.1:26657)" )
102+ }
103+
104+ // 3. Ask for Google API key (optional)
105+ fmt .Println ()
106+ fmt .Println ("🔍 AI-Powered Proposals (Optional)" )
107+ fmt .Println ("───────────────────────────────────" )
108+ fmt .Println ("Enable AI to automatically research and propose values using Google Gemini." )
57109 fmt .Println ()
58110 fmt .Print ("Enter Google API Key (leave empty to skip): " )
59111
60- reader := bufio .NewReader (os .Stdin )
61112 apiKey , _ := reader .ReadString ('\n' )
62113 apiKey = strings .TrimSpace (apiKey )
63114
@@ -73,16 +124,17 @@ func NewConfigInitCmd() *cobra.Command {
73124 return err
74125 }
75126
127+ // Display summary
76128 fmt .Println ()
77129 utils .PrintSuccess (fmt .Sprintf ("Config file created at %s" , configPath ))
78130 fmt .Println ()
79131 fmt .Println ("Configuration:" )
80- fmt .Printf (" Key Name: %s\n " , cfg .KeyName )
81- fmt .Printf (" Realm Path: %s\n " , cfg .RealmPath )
82- fmt .Printf (" Chain ID: %s\n " , cfg .ChainID )
83- fmt .Printf (" Remote: %s\n " , cfg .Remote )
84- fmt .Printf (" Gas Fee: %s\n " , cfg .GasFee )
85- fmt .Printf (" Gas Wanted: %d\n " , cfg .GasWanted )
132+ fmt .Printf (" Key Name: %s\n " , cfg .KeyName )
133+ fmt .Printf (" Realm Path: %s\n " , cfg .RealmPath )
134+ fmt .Printf (" Chain ID: %s\n " , cfg .ChainID )
135+ fmt .Printf (" Remote: %s\n " , cfg .Remote )
136+ fmt .Printf (" Gas Fee: %s\n " , cfg .GasFee )
137+ fmt .Printf (" Gas Wanted: %d\n " , cfg .GasWanted )
86138 if cfg .GoogleAPIKey != "" {
87139 maskedKey := cfg .GoogleAPIKey
88140 if len (maskedKey ) > 8 {
@@ -93,11 +145,11 @@ func NewConfigInitCmd() *cobra.Command {
93145 fmt .Printf (" Google API Key: (not configured)\n " )
94146 }
95147 fmt .Println ()
96- fmt .Println ("Edit this file to customize your settings. " )
148+ fmt .Println ("💡 You can edit this file anytime: ~/.goo/config.yaml " )
97149
98150 if cfg .GoogleAPIKey == "" {
99151 fmt .Println ()
100- fmt .Println ("💡 To enable AI-powered proposals:" )
152+ fmt .Println ("To enable AI-powered proposals later :" )
101153 fmt .Println (" 1. Get a free API key: https://makersuite.google.com/app/apikey" )
102154 fmt .Println (" 2. Edit ~/.goo/config.yaml and add:" )
103155 fmt .Println (" google_api_key: your-api-key-here" )
@@ -108,6 +160,8 @@ func NewConfigInitCmd() *cobra.Command {
108160 },
109161 }
110162
163+ cmd .Flags ().BoolVarP (& force , "force" , "f" , false , "Overwrite existing configuration file" )
164+
111165 return cmd
112166}
113167
0 commit comments