-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (42 loc) · 1.35 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// OSMON
// Author: Daniel Debny - github.com/debek
// Year: 24.12.2023
// Description: An application for displaying system information in the terminal.
package main
import (
"flag"
"fmt"
"os"
)
func main() {
var interval intervalFlag
var helpFlag bool
var versionFlag bool
flag.Usage = displayHelp
flag.Var(&interval, "i", "Set interval for refreshing the display in seconds (shorthand)")
flag.Var(&interval, "interval", "Set interval for refreshing the display in seconds")
flag.BoolVar(&helpFlag, "h", false, "Display help information (shorthand)")
flag.BoolVar(&helpFlag, "help", false, "Display help information")
flag.BoolVar(&versionFlag, "v", false, "Display the version of the application (shorthand)")
flag.BoolVar(&versionFlag, "version", false, "Display the version of the application")
flag.Parse()
if versionFlag {
appVersion := os.Getenv("APP_VERSION")
if appVersion == "" {
appVersion = "development"
}
fmt.Printf("Osmon version %s\n", appVersion)
os.Exit(0)
}
if helpFlag {
displayHelp()
os.Exit(0)
}
if interval.set {
// Display system information at intervals
displaySystemInfoAtInterval(interval.value)
} else {
// Display system information once
displaySystemInfo()
}
}