mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-19 20:10:58 +01:00
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
|
package cmd
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/ddworken/hishtory/client/data"
|
||
|
"github.com/ddworken/hishtory/client/hctx"
|
||
|
"github.com/ddworken/hishtory/client/lib"
|
||
|
"github.com/spf13/cobra"
|
||
|
)
|
||
|
|
||
|
var verbose *bool
|
||
|
|
||
|
var statusCmd = &cobra.Command{
|
||
|
Use: "status",
|
||
|
Short: "Get the hishtory status",
|
||
|
Run: func(cmd *cobra.Command, args []string) {
|
||
|
ctx := hctx.MakeContext()
|
||
|
config := hctx.GetConf(ctx)
|
||
|
fmt.Printf("hiSHtory: v0.%s\nEnabled: %v\n", lib.Version, config.IsEnabled)
|
||
|
fmt.Printf("Secret Key: %s\n", config.UserSecret)
|
||
|
if *verbose {
|
||
|
fmt.Printf("User ID: %s\n", data.UserId(config.UserSecret))
|
||
|
fmt.Printf("Device ID: %s\n", config.DeviceId)
|
||
|
printDumpStatus(config)
|
||
|
}
|
||
|
fmt.Printf("Commit Hash: %s\n", lib.GitCommit)
|
||
|
},
|
||
|
}
|
||
|
|
||
|
func printDumpStatus(config hctx.ClientConfig) {
|
||
|
dumpRequests, err := lib.GetDumpRequests(config)
|
||
|
lib.CheckFatalError(err)
|
||
|
fmt.Printf("Dump Requests: ")
|
||
|
for _, d := range dumpRequests {
|
||
|
fmt.Printf("%#v, ", *d)
|
||
|
}
|
||
|
fmt.Print("\n")
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
rootCmd.AddCommand(statusCmd)
|
||
|
verbose = statusCmd.Flags().BoolP("verbose", "v", false, "Display verbose hiSHtory information")
|
||
|
}
|