add command line flags
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
2024-10-04 14:39:00 +10:00
parent 73eac1d9ea
commit 82811442a4
5 changed files with 142 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"log"
@@ -239,6 +240,10 @@ func AvgChart(f *excelize.File, worksheetName string, location string, avgCpuCol
func main() {
var err error
inputFile := flag.String("input", "input.json", "The filename from which to load historical data")
outputFile := flag.String("output", "book1.xlsx", "The filename to use when writing excel workbook")
flag.Parse()
// Create the workbook
f := excelize.NewFile()
defer func() {
@@ -252,7 +257,7 @@ func main() {
}
// Load the JSON data from file
file, err := os.Open("input.json")
file, err := os.Open(*inputFile)
if err != nil {
log.Fatalf("Failed to open input.json: %v", err)
}
@@ -271,7 +276,7 @@ func main() {
GenerateCharts(f, data.Tracking.VmCount, "VM Count", "N60")
// Save workbook
if err := f.SaveAs("Book1.xlsx"); err != nil {
if err := f.SaveAs(*outputFile); err != nil {
fmt.Println(err)
}
}