mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 13:47:05 +02:00
Use positional arguments for source and target in beam commands
This commit is contained in:
parent
3ab0ce1cc6
commit
20f1732858
4 changed files with 20 additions and 22 deletions
|
@ -16,7 +16,6 @@ Scotty. If not, see <https://www.gnu.org/licenses/>.
|
|||
package cli
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -24,6 +23,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.uploadedlobster.com/scotty/internal/backends"
|
||||
"go.uploadedlobster.com/scotty/internal/config"
|
||||
"go.uploadedlobster.com/scotty/internal/models"
|
||||
"go.uploadedlobster.com/scotty/internal/storage"
|
||||
)
|
||||
|
@ -36,13 +36,15 @@ func NewTransferCmd[
|
|||
cmd *cobra.Command,
|
||||
db *storage.Database,
|
||||
entity string,
|
||||
source string,
|
||||
target string,
|
||||
) (TransferCmd[E, I, R], error) {
|
||||
c := TransferCmd[E, I, R]{
|
||||
cmd: cmd,
|
||||
db: db,
|
||||
entity: entity,
|
||||
}
|
||||
err := c.resolveBackends()
|
||||
err := c.resolveBackends(source, target)
|
||||
if err != nil {
|
||||
return c, err
|
||||
}
|
||||
|
@ -59,15 +61,10 @@ type TransferCmd[E models.Backend, I models.ImportBackend, R models.ListensResul
|
|||
ImpBackend I
|
||||
}
|
||||
|
||||
func (c *TransferCmd[E, I, R]) resolveBackends() error {
|
||||
sourceConfig := GetServiceConfigFromFlag(c.cmd, "from")
|
||||
if sourceConfig == nil {
|
||||
cobra.CheckErr(errors.New("failed loading service configuration"))
|
||||
}
|
||||
targetConfig := GetServiceConfigFromFlag(c.cmd, "to")
|
||||
if targetConfig == nil {
|
||||
cobra.CheckErr(errors.New("failed loading service configuration"))
|
||||
}
|
||||
func (c *TransferCmd[E, I, R]) resolveBackends(source string, target string) error {
|
||||
sourceConfig, err := config.GetService(source)
|
||||
cobra.CheckErr(err)
|
||||
targetConfig, err := config.GetService(target)
|
||||
|
||||
// Initialize backends
|
||||
expBackend, err := backends.ResolveBackend[E](sourceConfig)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue