This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"cloudsave/pkg/repository"
|
||||
"cloudsave/pkg/sync"
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -38,23 +37,15 @@ func (p *SyncCmd) SetFlags(f *flag.FlagSet) {
|
||||
}
|
||||
|
||||
func (p *SyncCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
|
||||
games, err := p.Service.AllGames()
|
||||
|
||||
remoteCred := make(map[string]map[string]string)
|
||||
rs, err := remote.All()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "error: failed to load datastore:", err)
|
||||
fmt.Fprintln(os.Stderr, "error: failed to connect to the remote:", err)
|
||||
return subcommands.ExitFailure
|
||||
}
|
||||
|
||||
remoteCred := make(map[string]map[string]string)
|
||||
for _, g := range games {
|
||||
r, err := remote.One(g.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, remote.ErrNoRemote) {
|
||||
fmt.Println("⬛", g.Name+": no remote configured")
|
||||
continue
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, "error: failed to load datastore:", err)
|
||||
return subcommands.ExitFailure
|
||||
}
|
||||
for _, r := range rs {
|
||||
cli, err := connect(remoteCred, r)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "error: failed to connect to the remote:", err)
|
||||
@@ -92,7 +83,7 @@ func (p *SyncCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
|
||||
}
|
||||
})
|
||||
|
||||
syncer.SetErrorCallback(func(err error) {
|
||||
syncer.SetErrorCallback(func(err error, g repository.Metadata) {
|
||||
destroyPg()
|
||||
fmt.Println("❌", g.Name+": "+err.Error())
|
||||
})
|
||||
|
||||
@@ -35,6 +35,17 @@ func init() {
|
||||
datastorePath = filepath.Join(roaming, "cloudsave")
|
||||
}
|
||||
|
||||
func Get(server string) (string, string, error) {
|
||||
var err error
|
||||
store, err := load()
|
||||
if err == nil {
|
||||
if c, ok := store[server]; ok {
|
||||
return c.Username, c.Password, nil
|
||||
}
|
||||
}
|
||||
return "","",fmt.Errorf("not found")
|
||||
}
|
||||
|
||||
func Read(server string) (string, string, error) {
|
||||
var err error
|
||||
store, err := load()
|
||||
|
||||
Reference in New Issue
Block a user