summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/goprecords/main.go37
1 files changed, 19 insertions, 18 deletions
diff --git a/cmd/goprecords/main.go b/cmd/goprecords/main.go
index 7807d1f..c608f78 100644
--- a/cmd/goprecords/main.go
+++ b/cmd/goprecords/main.go
@@ -14,28 +14,26 @@ import (
const defaultDB = "goprecords.db"
func main() {
- for _, arg := range os.Args[1:] {
- if arg == "-version" || arg == "--version" {
- fmt.Println(version.Version)
- os.Exit(0)
- }
+ if len(os.Args) > 1 && (os.Args[1] == "-version" || os.Args[1] == "--version") {
+ fmt.Println(version.Version)
+ return
}
- if len(os.Args) >= 2 {
- switch os.Args[1] {
- case "import":
- runImport(os.Args[2:])
- return
- case "query":
- runQuery(os.Args[2:])
- return
- case "test":
- runTests()
- return
- }
+ if len(os.Args) < 2 {
+ runReportFromFiles(nil)
+ return
}
- runReportFromFiles(os.Args[1:])
+ switch os.Args[1] {
+ case "import":
+ runImport(os.Args[2:])
+ case "query":
+ runQuery(os.Args[2:])
+ case "test":
+ runTests()
+ default:
+ runReportFromFiles(os.Args[1:])
+ }
}
func runImport(args []string) {
@@ -146,6 +144,9 @@ func runQuery(args []string) {
}
func runReportFromFiles(args []string) {
+ if args == nil {
+ args = []string{}
+ }
fs := flag.NewFlagSet("goprecords", flag.ExitOnError)
statsDir := fs.String("stats-dir", "", "The uptimed raw record input dir (required)")
category := fs.String("category", "Host", "Category: Host, Kernel, KernelMajor, KernelName")