go-KodeStarter/configFile/config-actionyml.go

84 lines
1.9 KiB
Go
Raw Normal View History

2023-06-25 12:54:50 -04:00
package configFile
import (
"fmt"
2023-06-30 15:25:39 -04:00
"kode-creator/config"
2023-06-25 12:54:50 -04:00
"log"
"os"
)
2023-06-30 10:09:01 -04:00
func LoadConfigFile(c *config.Config) *ConfigYml {
2023-06-25 12:54:50 -04:00
2023-06-30 10:09:01 -04:00
filename := c.GetConfigFileYmlName()
cfgfile, err := LoadConfig(filename)
2023-06-25 12:54:50 -04:00
if err != nil {
log.Fatalf("error loading config file: %v", err)
os.Exit(1)
}
2023-06-30 10:09:01 -04:00
return cfgfile
2023-06-25 12:54:50 -04:00
}
2023-06-30 10:09:01 -04:00
func Listcategory(c *config.Config) {
2023-06-25 12:54:50 -04:00
2023-06-30 10:09:01 -04:00
cfg := LoadConfigFile(c)
2023-06-25 12:54:50 -04:00
// list all categories
ListCategories, err := cfg.GetListCategory()
if err != nil {
log.Fatalf("error getting categories: %v", err)
}
for _, c := range ListCategories {
fmt.Printf("Category: %s\n", c)
}
}
// // list all elements from category "Category-Go"
// ListSoftwares, err := cfg.GetListSoftware("Go")
// if err != nil {
// log.Fatalf("error getting logiciels: %v", err)
// }
// for _, s := range ListSoftwares {
// fmt.Printf("Software: %s\n", s)
// Software, err := cfg.GetSoftware("Go", s)
// if err != nil {
// log.Fatalf("error getting logiciel: %v", err)
// }
// fmt.Printf("Nom: %s\n", Software.Name)
// fmt.Printf("Version: %s\n", Software.Version)
// fmt.Printf("Auteur: %s\n", Software.Author)
// fmt.Printf("Location: %s\n", Software.Location)
// fmt.Printf("Description: %s\n", Software.Description)
// }
// EnvironmentVariables, err := cfg.GetListEnvironmentVariables("Go")
// if err != nil {
// log.Fatalf("error getting environment variables: %v", err)
// }
// for _, e := range EnvironmentVariables {
// fmt.Printf("Environment variable: %s\n", e)
// EnvVar, err := cfg.GetEnvironmentVariables("Go", e)
// if err != nil {
// log.Fatalf("error getting environment variable: %v", err)
// }
// fmt.Printf("%s = %s\n", e, EnvVar)
// }
// liste configuration elements for "directory"
// Dir, err := cfg.GetDirectory("Category-Go", "source")
// if err != nil {
// log.Fatalf("error getting directory: %v", err)
// }
// for _, d := range Dir.Path {
// fmt.Printf("Directory: %s\n", d)
// }
// os.Exit(0)