fs: convert main options to new config system

There are some flags which haven't been converted which could be
converted in the future.
This commit is contained in:
Nick Craig-Wood
2024-07-09 18:42:01 +01:00
parent c2bf300dd8
commit 4d2bc190cc
6 changed files with 726 additions and 329 deletions

View File

@ -14,7 +14,6 @@ import (
"os"
"os/exec"
"path"
"regexp"
"runtime"
"runtime/pprof"
"strconv"
@ -49,7 +48,6 @@ var (
cpuProfile = flags.StringP("cpuprofile", "", "", "Write cpu profile to file", "Debugging")
memProfile = flags.StringP("memprofile", "", "", "Write memory profile to file", "Debugging")
statsInterval = flags.DurationP("stats", "", time.Minute*1, "Interval between printing stats, e.g. 500ms, 60s, 5m (0 to disable)", "Logging")
dataRateUnit = flags.StringP("stats-unit", "", "bytes", "Show data rate in stats as either 'bits' or 'bytes' per second", "Logging")
version bool
// Errors
errorCommandNotFound = errors.New("command not found")
@ -472,13 +470,6 @@ func initConfig() {
}
})
}
if m, _ := regexp.MatchString("^(bits|bytes)$", *dataRateUnit); !m {
fs.Errorf(nil, "Invalid unit passed to --stats-unit. Defaulting to bytes.")
ci.DataRateUnit = "bytes"
} else {
ci.DataRateUnit = *dataRateUnit
}
}
func resolveExitCode(err error) {