mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-21 04:19:27 +02:00
Implemented "beam --timestamp {n}"
This commit is contained in:
parent
4d18a207ee
commit
27685d617a
4 changed files with 11 additions and 2 deletions
|
@ -47,6 +47,7 @@ func init() {
|
|||
beamCmd.MarkPersistentFlagRequired("from")
|
||||
beamCmd.PersistentFlags().StringP("to", "t", "", "Target backend configuration (required)")
|
||||
beamCmd.MarkPersistentFlagRequired("to")
|
||||
beamCmd.PersistentFlags().Int64P("timestamp", "s", 0, "Only import data newer then given Unix timestamp")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
|
|
|
@ -36,3 +36,11 @@ func getConfigFromFlag(cmd *cobra.Command, flagName string) (string, *viper.Vipe
|
|||
}
|
||||
return configName, config
|
||||
}
|
||||
|
||||
func getInt64FromFlag(cmd *cobra.Command, flagName string) (result int64) {
|
||||
result, err := cmd.Flags().GetInt64(flagName)
|
||||
if err != nil {
|
||||
result = 0
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ var listensCmd = &cobra.Command{
|
|||
cobra.CheckErr(err)
|
||||
importBackend, err := backends.ResolveBackend[models.ListensImport](targetConfig)
|
||||
cobra.CheckErr(err)
|
||||
timestamp := time.Unix(0, 0)
|
||||
timestamp := time.Unix(getInt64FromFlag(cmd, "timestamp"), 0)
|
||||
listens, err := exportBackend.ExportListens(timestamp)
|
||||
cobra.CheckErr(err)
|
||||
result, err := importBackend.ImportListens(listens, timestamp)
|
||||
|
|
|
@ -43,7 +43,7 @@ var lovesCmd = &cobra.Command{
|
|||
cobra.CheckErr(err)
|
||||
importBackend, err := backends.ResolveBackend[models.LovesImport](targetConfig)
|
||||
cobra.CheckErr(err)
|
||||
timestamp := time.Unix(0, 0)
|
||||
timestamp := time.Unix(getInt64FromFlag(cmd, "timestamp"), 0)
|
||||
loves, err := exportBackend.ExportLoves(timestamp)
|
||||
cobra.CheckErr(err)
|
||||
result, err := importBackend.ImportLoves(loves, timestamp)
|
||||
|
|
Loading…
Add table
Reference in a new issue