From 3e40d34f65736b5a1d0c8ee6cee9dcbebb88b5d0 Mon Sep 17 00:00:00 2001 From: aryansharma9917 Date: Sun, 4 Jan 2026 22:10:25 +0530 Subject: [PATCH 1/3] Updated config file --- cmd/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/config.go b/cmd/config.go index a793f2c..f942b15 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -18,7 +18,7 @@ var configInitCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { path, err := config.InitConfig() if err != nil { - fmt.Println("ℹ️", err.Error()) + fmt.Println("ℹ", err.Error()) return } fmt.Println("Config created at:", path) From a99d0e5bb3a23530b5b4752bb2eb16cf0c5f1083 Mon Sep 17 00:00:00 2001 From: aryansharma9917 Date: Sun, 4 Jan 2026 22:52:29 +0530 Subject: [PATCH 2/3] Updated config file --- cmd/config.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index f942b15..0fdc58a 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -18,14 +18,28 @@ var configInitCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { path, err := config.InitConfig() if err != nil { - fmt.Println("ℹ", err.Error()) + fmt.Println("ℹ️", err.Error()) return } - fmt.Println("Config created at:", path) + fmt.Println("✅ Config created at:", path) + }, +} + +var configViewCmd = &cobra.Command{ + Use: "view", + Short: "View Codewise config", + Run: func(cmd *cobra.Command, args []string) { + data, err := config.ReadConfig() + if err != nil { + fmt.Println("ℹ️", err.Error()) + return + } + fmt.Println(string(data)) }, } func init() { configCmd.AddCommand(configInitCmd) + configCmd.AddCommand(configViewCmd) rootCmd.AddCommand(configCmd) } From 000d5147cb0f72655105ed7c4e6c7f78e670cb2d Mon Sep 17 00:00:00 2001 From: aryansharma9917 Date: Sun, 4 Jan 2026 22:53:29 +0530 Subject: [PATCH 3/3] Added init and view commanmd --- pkg/config/config.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 14500d6..13e859e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -47,3 +47,19 @@ func InitConfig() (string, error) { return configPath, nil } + +// ReadConfig reads and returns the config file contents +func ReadConfig() ([]byte, error) { + home, err := os.UserHomeDir() + if err != nil { + return nil, err + } + + configPath := filepath.Join(home, ConfigDirName, ConfigFileName) + + if _, err := os.Stat(configPath); err != nil { + return nil, fmt.Errorf("config file not found") + } + + return os.ReadFile(configPath) +}