|
|
@@ -2,7 +2,7 @@ package flags
|
|
|
|
|
|
import (
|
|
|
"flag"
|
|
|
- "log"
|
|
|
+ "fmt"
|
|
|
"os"
|
|
|
"runtime"
|
|
|
"strings"
|
|
|
@@ -25,13 +25,14 @@ func (flags *Flags) ParseFlags() {
|
|
|
flag.IntVar(&flags.Controller.Split, "split", 1, "Split the tasks in n parts. This depends on the availability of the first row.")
|
|
|
flag.IntVar(&flags.Controller.Part, "part", 1, "Process part x in n parts. Cannot be lower than 1, or higher than specified in split.")
|
|
|
flag.StringVar(&flags.Controller.Output, "output", "human", "Type of output. 'human' for human readable. 'flat' for flat as stored in memory output. 'json' for JSON output.")
|
|
|
+ flag.StringVar(&flags.Controller.Print, "print", "short", "'short': normal output;'long': normal output with timestamps; 'silent': Only print the results;")
|
|
|
|
|
|
// Parse the flags
|
|
|
flag.Parse()
|
|
|
|
|
|
// Process any changes to the CPU usage.
|
|
|
if flags.Controller.NumCPUs <= 0 {
|
|
|
- log.Printf("ERROR: Number of CPU cores must be 1 or higher.\n\n")
|
|
|
+ fmt.Printf("ERROR: Number of CPU cores must be 1 or higher.\n\n")
|
|
|
flags.printUsage()
|
|
|
os.Exit(1)
|
|
|
}
|
|
|
@@ -42,7 +43,7 @@ func (flags *Flags) ParseFlags() {
|
|
|
|
|
|
// Process rows
|
|
|
if flags.Controller.Row1 == "000000000" || flags.Controller.Row2 == "000000000" || flags.Controller.Row3 == "000000000" || flags.Controller.Row4 == "000000000" || flags.Controller.Row5 == "000000000" || flags.Controller.Row6 == "000000000" || flags.Controller.Row7 == "000000000" || flags.Controller.Row8 == "000000000" || flags.Controller.Row9 == "000000000" {
|
|
|
- log.Printf("ERROR: All parameters must be entered.\n\n")
|
|
|
+ fmt.Printf("ERROR: All parameters must be entered.\n\n")
|
|
|
flags.printUsage()
|
|
|
os.Exit(1)
|
|
|
}
|
|
|
@@ -61,14 +62,14 @@ func (flags *Flags) ParseFlags() {
|
|
|
// Process workload splitting
|
|
|
// Ensure split and part are 1 or higher
|
|
|
if flags.Controller.Split <= 0 || flags.Controller.Part <= 0 {
|
|
|
- log.Printf("ERROR: '-split' and '-part' need to be 1 or higher.\n")
|
|
|
+ fmt.Printf("ERROR: '-split' and '-part' need to be 1 or higher.\n")
|
|
|
flags.printUsage()
|
|
|
os.Exit(1)
|
|
|
}
|
|
|
|
|
|
// Ensure part is between 1 and split
|
|
|
if flags.Controller.Part > flags.Controller.Split {
|
|
|
- log.Printf("ERROR: '-part' cannot be bigger than `-split`.\n")
|
|
|
+ fmt.Printf("ERROR: '-part' cannot be bigger than `-split`.\n")
|
|
|
flags.printUsage()
|
|
|
os.Exit(1)
|
|
|
}
|
|
|
@@ -76,7 +77,15 @@ func (flags *Flags) ParseFlags() {
|
|
|
// Process output selection
|
|
|
flags.Controller.Output = strings.ToLower(flags.Controller.Output)
|
|
|
if flags.Controller.Output != "human" && flags.Controller.Output != "flat" && flags.Controller.Output != "json" {
|
|
|
- log.Printf("ERROR: Invalid output, can only be 'human' or 'flat'.\n")
|
|
|
+ fmt.Printf("ERROR: Invalid output, can only be 'human' or 'flat' or 'json'.\n")
|
|
|
+ flags.printUsage()
|
|
|
+ os.Exit(1)
|
|
|
+ }
|
|
|
+
|
|
|
+ // Process print selection
|
|
|
+ flags.Controller.Print = strings.ToLower(flags.Controller.Print)
|
|
|
+ if flags.Controller.Print != "short" && flags.Controller.Print != "long" && flags.Controller.Print != "silent" {
|
|
|
+ fmt.Printf("ERROR: Invalid Print, can only be 'short' or 'long' or 'silent'.\n")
|
|
|
flags.printUsage()
|
|
|
os.Exit(1)
|
|
|
}
|