@@ -17,29 +17,40 @@ import (
1717var validateCmd = & cobra.Command {
1818 Use : "validate" ,
1919 Short : "Validate a digger.yml file" ,
20- Long : `Validate a digger.yml file` ,
20+ Long : `Validate the structure and contents of a digger.yml file. ` ,
2121 Run : func (cmd * cobra.Command , args []string ) {
22- _ , configYaml , _ , err := digger_config .LoadDiggerConfig ("./" , true , nil )
22+ configPath := "./"
23+ log .Printf ("Starting validation of digger.yml in path: %s" , configPath )
24+
25+ // Load the Digger config file
26+ _ , configYaml , _ , err := digger_config .LoadDiggerConfig (configPath , true , nil )
2327 if err != nil {
24- log .Printf ("Invalid digger config file: %v. Exiting." , err )
28+ log .Printf ("Error loading digger.yml: %v" , err )
29+ fmt .Fprintf (os .Stderr , "Invalid digger config file: %v\n " , err )
2530 os .Exit (1 )
2631 }
27- log .Printf ("digger.yml loaded successfully, here is your configuration:" )
28- s , _ := json .MarshalIndent (configYaml , "" , "\t " )
29- fmt .Println (string (s ))
32+
33+ // Log success message
34+ log .Printf ("digger.yml loaded successfully." )
35+
36+ // Display the configuration in a pretty JSON format
37+ prettyConfig , err := json .MarshalIndent (configYaml , "" , "\t " )
38+ if err != nil {
39+ log .Printf ("Error formatting digger.yml: %v" , err )
40+ fmt .Fprintf (os .Stderr , "Error formatting digger config file: %v\n " , err )
41+ os .Exit (1 )
42+ }
43+
44+ // Print the formatted configuration
45+ fmt .Println ("Configuration:" )
46+ fmt .Println (string (prettyConfig ))
3047 },
3148}
3249
3350func init () {
3451 rootCmd .AddCommand (validateCmd )
3552
36- // Here you will define your flags and configuration settings.
37-
38- // Cobra supports Persistent Flags which will work for this command
39- // and all subcommands, e.g.:
40- // validateCmd.PersistentFlags().String("foo", "", "A help for foo")
41-
42- // Cobra supports local flags which will only run when this command
43- // is called directly, e.g.:
44- // validateCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
53+ // Optionally define any flags that you want to use with the command here
54+ // e.g.:
55+ // validateCmd.Flags().StringP("config", "c", "", "Specify custom config file path")
4556}
0 commit comments