push stuff
This commit is contained in:
parent
3621c11a61
commit
b9bebe7dd3
1 changed files with 43 additions and 14 deletions
43
main.go
43
main.go
|
@ -1,10 +1,13 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/csv"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config represents the structure of the config.json file.
|
// Config represents the structure of the config.json file.
|
||||||
|
@ -37,13 +40,39 @@ func main() {
|
||||||
log.Fatalf("Error parsing JSON: %v", err)
|
log.Fatalf("Error parsing JSON: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the parsed configuration
|
// Print the display texts of all modules as a comma-separated list
|
||||||
fmt.Printf("Base Dir: %s\n", config.BaseDir)
|
fmt.Println("Display Texts of Modules:")
|
||||||
for _, module := range config.Modules {
|
for _, module := range config.Modules {
|
||||||
fmt.Printf("Module Name: %s\n", module.Name)
|
displayTexts := []string{}
|
||||||
fmt.Printf(" Path: %s\n", module.Path)
|
csvFilePath := config.BaseDir + "/" + module.CSVFile
|
||||||
fmt.Printf(" CSV File: %s\n", module.CSVFile)
|
|
||||||
fmt.Printf(" Default Language: %s\n", module.DefaultLanguage)
|
// Open and read the CSV file
|
||||||
fmt.Printf(" Default Variants: %v\n", module.DefaultVariants)
|
csvFile, err := os.Open(csvFilePath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error opening CSV file %s: %v", csvFilePath, err)
|
||||||
|
}
|
||||||
|
defer csvFile.Close()
|
||||||
|
|
||||||
|
reader := csv.NewReader(csvFile)
|
||||||
|
records, err := reader.ReadAll()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error reading CSV file %s: %v", csvFilePath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore the first line
|
||||||
|
if len(records) > 1 {
|
||||||
|
records = records[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, record := range records {
|
||||||
|
displayTexts = append(displayTexts, record[1]) // Assuming the display text is in the second column (index 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("- Module Name: %s (%s)\n", module.Name, commaSeparated(displayTexts))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function to join a slice of strings with commas
|
||||||
|
func commaSeparated(slice []string) string {
|
||||||
|
return fmt.Sprintf("[%s]", strings.Join(slice, ", "))
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue