Skip to content

Commit

Permalink
Some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
debek committed Jan 26, 2024
1 parent caadf93 commit 9a155f4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ Special thanks to the Go community for creating excellent libraries like `github

## TO DO

- **osmon --version -> OSInfo version development - fix this problem
- ** Add help if you would give unexpected argument
- **Information about IOBS and IOPS**: Include details about read and write operations, and possibly any limits.
- **Outgoing and Incoming Connections**: Display connections in kilobits or megabits.
- **Number of Connections**: Show the count of incoming and outgoing connections.
- **Kernel Version**: Add information about the kernel version.
- **Kernel Version**: Add information about the kernel version.
3 changes: 1 addition & 2 deletions display.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ import (

func displaySystemInfoInInterval(interval time.Duration) {
for {
clearScreen() // Pozostawione w tej funkcji
clearScreen()
displaySystemInfo()
time.Sleep(interval)
}
}

func displaySystemInfo() {
// Usunięto wywołanie clearScreen() stąd
currentUser, err := user.Current()
if err != nil {
fmt.Printf("Failed to get current user: %s\n", err)
Expand Down
7 changes: 5 additions & 2 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ import (
"flag"
"fmt"
"strconv"
"time"
)

type intervalFlag struct {
set bool
value int
value time.Duration
}

// Set is a method called by the flag package when the flag is set.
func (f *intervalFlag) Set(s string) error {
f.set = true
var seconds int
var err error
f.value, err = strconv.Atoi(s)
seconds, err = strconv.Atoi(s)
if err != nil {
return fmt.Errorf("invalid format for interval: %v", err)
}
f.value = time.Duration(seconds) * time.Second
return nil
}

Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"flag"
"fmt"
"os"
"time"
)

func main() {
Expand All @@ -31,7 +30,7 @@ func main() {
if appVersion == "" {
appVersion = "development"
}
fmt.Printf("OSInfo version %s\n", appVersion)
fmt.Printf("Osmon version %s\n", appVersion)
os.Exit(0)
}

Expand All @@ -41,8 +40,10 @@ func main() {
}

if interval.set {
displaySystemInfoInInterval(time.Duration(interval.value) * time.Second)
// Display system information in interval
displaySystemInfoInInterval(interval.value)
} else {
// Display system information once
displaySystemInfo()
}
}

0 comments on commit 9a155f4

Please sign in to comment.