mirror of
https://github.com/Adembc/lazyssh.git
synced 2026-07-14 12:13:34 +02:00
format last ssh duration
This commit is contained in:
@@ -23,7 +23,6 @@ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc
|
|||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
|
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
|
||||||
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
|
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
|
||||||
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
|
||||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M=
|
github.com/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M=
|
||||||
github.com/spf13/pflag v1.0.7/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.7/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
@@ -32,8 +31,6 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
|
|||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
|
|
||||||
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||||
|
|||||||
@@ -80,12 +80,30 @@ func humanizeDuration(t time.Time) string {
|
|||||||
if d < time.Minute {
|
if d < time.Minute {
|
||||||
return "just now"
|
return "just now"
|
||||||
}
|
}
|
||||||
h := int(d.Hours())
|
if d < time.Hour {
|
||||||
m := int(d.Minutes()) % 60
|
m := int(d.Minutes())
|
||||||
if h > 0 {
|
return fmt.Sprintf("%dm ago", m)
|
||||||
return fmt.Sprintf("%dh%dm ago", h, m)
|
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%dm ago", m)
|
if d < 48*time.Hour {
|
||||||
|
h := int(d.Hours())
|
||||||
|
return fmt.Sprintf("%dh ago", h)
|
||||||
|
}
|
||||||
|
if d < 60*24*time.Hour {
|
||||||
|
days := int(d.Hours()) / 24
|
||||||
|
return fmt.Sprintf("%dd ago", days)
|
||||||
|
}
|
||||||
|
if d < 365*24*time.Hour {
|
||||||
|
months := int(d.Hours()) / (24 * 30)
|
||||||
|
if months < 1 {
|
||||||
|
months = 1
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%dmo ago", months)
|
||||||
|
}
|
||||||
|
years := int(d.Hours()) / (24 * 365)
|
||||||
|
if years < 1 {
|
||||||
|
years = 1
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%dy ago", years)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildSSHCommand constructs a ready-to-run ssh command for the given server.
|
// BuildSSHCommand constructs a ready-to-run ssh command for the given server.
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ check: staticcheck ## Run staticcheck analyzer
|
|||||||
$(STATICCHECK) ./...
|
$(STATICCHECK) ./...
|
||||||
|
|
||||||
.PHONY: quality
|
.PHONY: quality
|
||||||
quality: fmt vet ## Run all code quality checks (i will add lint and check)
|
quality: fmt vet lint ## Run all code quality checks
|
||||||
|
|
||||||
##@ Testing
|
##@ Testing
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user