84 lines
1.9 KiB
Go
84 lines
1.9 KiB
Go
package configFile
|
|
|
|
import (
|
|
"fmt"
|
|
"kode-creator/config"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
func LoadConfigFile(c *config.Config) *ConfigYml {
|
|
|
|
filename := c.GetConfigFileYmlName()
|
|
cfgfile, err := LoadConfig(filename)
|
|
if err != nil {
|
|
log.Fatalf("error loading config file: %v", err)
|
|
os.Exit(1)
|
|
}
|
|
return cfgfile
|
|
|
|
}
|
|
|
|
func Listcategory(c *config.Config) {
|
|
|
|
cfg := LoadConfigFile(c)
|
|
|
|
// 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)
|