Add verbose flag for the status subcommand

This commit is contained in:
David Dworken 2022-04-16 10:46:57 -07:00
parent 2b676a935b
commit def83d6b0e
2 changed files with 15 additions and 11 deletions

View File

@ -709,13 +709,17 @@ func TestDisplayTable(t *testing.T) {
userSecret := installHishtory(t, "") userSecret := installHishtory(t, "")
// Submit two fake entries // Submit two fake entries
tmz, err := time.LoadLocation("America/Los_Angeles")
if err != nil {
t.Fatalf("failed to load timezone: %v", err)
}
entry1 := data.MakeFakeHistoryEntry("table_cmd1") entry1 := data.MakeFakeHistoryEntry("table_cmd1")
entry1.StartTime = time.Unix(1650096186, 0) entry1.StartTime = time.Unix(1650096186, 0).In(tmz)
entry1.EndTime = time.Unix(1650096190, 0) entry1.EndTime = time.Unix(1650096190, 0).In(tmz)
manuallySubmitHistoryEntry(t, userSecret, entry1) manuallySubmitHistoryEntry(t, userSecret, entry1)
entry2 := data.MakeFakeHistoryEntry("table_cmd2") entry2 := data.MakeFakeHistoryEntry("table_cmd2")
entry2.StartTime = time.Unix(1650096196, 0) entry2.StartTime = time.Unix(1650096196, 0).In(tmz)
entry2.EndTime = time.Unix(1650096220, 0) entry2.EndTime = time.Unix(1650096220, 0).In(tmz)
entry2.CurrentWorkingDirectory = "~/foo/" entry2.CurrentWorkingDirectory = "~/foo/"
entry2.ExitCode = 3 entry2.ExitCode = 3
manuallySubmitHistoryEntry(t, userSecret, entry2) manuallySubmitHistoryEntry(t, userSecret, entry2)

View File

@ -44,13 +44,13 @@ func main() {
case "status": case "status":
config, err := lib.GetConfig() config, err := lib.GetConfig()
lib.CheckFatalError(err) lib.CheckFatalError(err)
fmt.Print("Hishtory: v0." + Version + "\nEnabled: ") fmt.Printf("Hishtory: v0.%s\nEnabled: %v\n", Version, config.IsEnabled)
fmt.Print(config.IsEnabled) fmt.Printf("Secret Key: %s\n", config.UserSecret)
fmt.Print("\nSecret Key: ") if len(os.Args) == 3 && os.Args[2] == "-v" {
fmt.Print(config.UserSecret) fmt.Printf("User ID: %s\n", data.UserId(config.UserSecret))
fmt.Print("\nCommit Hash: ") fmt.Printf("Device ID: %s\n", config.DeviceId)
fmt.Print(GitCommit) }
fmt.Print("\n") fmt.Printf("Commit Hash: %s\n", GitCommit)
case "update": case "update":
lib.CheckFatalError(lib.Update("https://api.hishtory.dev/download/hishtory-linux-amd64")) lib.CheckFatalError(lib.Update("https://api.hishtory.dev/download/hishtory-linux-amd64"))
default: default: