Use positional arguments for source and target in beam commands

This commit is contained in:
Philipp Wolfer 2023-12-08 17:59:37 +01:00
parent 3ab0ce1cc6
commit 20f1732858
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
4 changed files with 20 additions and 22 deletions

View file

@ -26,9 +26,10 @@ import (
)
var beamLovesCmd = &cobra.Command{
Use: "loves",
Use: "loves SOURCE TARGET",
Short: "Transfer loves between two services",
Long: `Transfers loves between two configured services.`,
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
db, err := storage.New(config.DatabasePath())
cobra.CheckErr(err)
@ -36,7 +37,7 @@ var beamLovesCmd = &cobra.Command{
models.LovesExport,
models.LovesImport,
models.LovesResult,
](cmd, &db, "loves")
](cmd, &db, "loves", args[0], args[1])
cobra.CheckErr(err)
exp := backends.LovesExportProcessor{Backend: c.ExpBackend}
imp := backends.LovesImportProcessor{Backend: c.ImpBackend}
@ -57,4 +58,5 @@ func init() {
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// beamLovesCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
beamLovesCmd.Flags().Int64P("timestamp", "t", 0, "Only import loves newer then given Unix timestamp")
}