Add getTimestamp command as an internal command that will be used as an alternative to date since date on MacOS doesn't support nanosecond granularity

This commit is contained in:
David Dworken 2023-11-18 12:01:40 -08:00
parent 8690d87a16
commit d8b83b9429
No known key found for this signature in database

View File

@ -24,6 +24,15 @@ import (
"gorm.io/gorm"
)
var getTimestampCmd = &cobra.Command{
Use: "getTimestamp",
Hidden: true,
Short: "[Internal-only] Returns a timestamp in Unix nanoseconds",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(time.Now().UnixNano())
},
}
var saveHistoryEntryCmd = &cobra.Command{
Use: "saveHistoryEntry",
Hidden: true,
@ -293,11 +302,6 @@ func deletePresavedEntries(ctx context.Context, entry *data.HistoryEntry, isRetr
return nil
}
func init() {
rootCmd.AddCommand(saveHistoryEntryCmd)
rootCmd.AddCommand(presaveHistoryEntryCmd)
}
func handleDumpRequests(ctx context.Context, dumpRequests []*shared.DumpRequest) error {
db := hctx.GetDb(ctx)
config := hctx.GetConf(ctx)
@ -636,3 +640,9 @@ func getCwdWithoutSubstitution() (string, error) {
}
return "", err
}
func init() {
rootCmd.AddCommand(saveHistoryEntryCmd)
rootCmd.AddCommand(presaveHistoryEntryCmd)
rootCmd.AddCommand(getTimestampCmd)
}