mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
Use config.ServiceConfig across API
This commit is contained in:
parent
091b3c2f49
commit
9c363cc06d
27 changed files with 137 additions and 99 deletions
|
@ -16,6 +16,7 @@ Scotty. If not, see <https://www.gnu.org/licenses/>.
|
|||
package cli
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -59,8 +60,14 @@ type TransferCmd[E models.Backend, I models.ImportBackend, R models.ListensResul
|
|||
}
|
||||
|
||||
func (c *TransferCmd[E, I, R]) resolveBackends() error {
|
||||
sourceName, sourceConfig := GetConfigFromFlag(c.cmd, "from")
|
||||
targetName, targetConfig := GetConfigFromFlag(c.cmd, "to")
|
||||
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"))
|
||||
}
|
||||
|
||||
// Initialize backends
|
||||
expBackend, err := backends.ResolveBackend[E](sourceConfig)
|
||||
|
@ -72,8 +79,8 @@ func (c *TransferCmd[E, I, R]) resolveBackends() error {
|
|||
return err
|
||||
}
|
||||
|
||||
c.sourceName = sourceName
|
||||
c.targetName = targetName
|
||||
c.sourceName = sourceConfig.Name
|
||||
c.targetName = targetConfig.Name
|
||||
c.ExpBackend = expBackend
|
||||
c.ImpBackend = impBackend
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue