fixes
This commit is contained in:
@@ -49,7 +49,7 @@ func (p *SyncCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
|
||||
r, err := remote.One(g.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, remote.ErrNoRemote) {
|
||||
fmt.Println(g.Name + ": no remote configured")
|
||||
fmt.Println("⬛", g.Name+": no remote configured")
|
||||
continue
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, "error: failed to load datastore:", err)
|
||||
@@ -88,7 +88,7 @@ func (p *SyncCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
|
||||
slog.Warn("failed to push backup files", "err", err)
|
||||
}
|
||||
destroyPg()
|
||||
fmt.Println(g.Name + ": pushed")
|
||||
fmt.Println("⬆️", g.Name+": pushed")
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ func (p *SyncCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
|
||||
continue
|
||||
}
|
||||
}
|
||||
fmt.Println(g.Name + ": already up-to-date")
|
||||
fmt.Println("🆗", g.Name+": already up-to-date")
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -132,13 +132,13 @@ func (p *SyncCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
|
||||
return subcommands.ExitFailure
|
||||
}
|
||||
destroyPg()
|
||||
fmt.Println(g.Name + ": pushed")
|
||||
fmt.Println("⬆️", g.Name+": pushed")
|
||||
continue
|
||||
}
|
||||
|
||||
if g.Version < remoteMetadata.Version {
|
||||
destroyPg()
|
||||
if err := p.pull(r.GameID, cli); err != nil {
|
||||
if err := p.pull(g, cli); err != nil {
|
||||
destroyPg()
|
||||
fmt.Fprintln(os.Stderr, "failed to push:", err)
|
||||
return subcommands.ExitFailure
|
||||
@@ -152,7 +152,7 @@ func (p *SyncCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{})
|
||||
fmt.Fprintln(os.Stderr, "failed to push:", err)
|
||||
return subcommands.ExitFailure
|
||||
}
|
||||
fmt.Println(g.Name + ": pulled")
|
||||
fmt.Println("⬇️", g.Name+": pulled")
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ func (p *SyncCmd) conflict(gameID string, m, remoteMetadata repository.Metadata,
|
||||
return nil
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Println("--- /!\\ CONFLICT ---")
|
||||
fmt.Println("--- ⚠️ CONFLICT ---")
|
||||
fmt.Println(g.Name, "(", g.Path, ")")
|
||||
fmt.Println("----")
|
||||
fmt.Println("Your version:", g.Date.Format(time.RFC1123))
|
||||
@@ -198,7 +198,7 @@ func (p *SyncCmd) conflict(gameID string, m, remoteMetadata repository.Metadata,
|
||||
|
||||
case prompt.Their:
|
||||
{
|
||||
if err := p.pull(gameID, cli); err != nil {
|
||||
if err := p.pull(g, cli); err != nil {
|
||||
return fmt.Errorf("failed to push: %w", err)
|
||||
}
|
||||
g.Version = remoteMetadata.Version
|
||||
@@ -266,8 +266,11 @@ func (p *SyncCmd) pullBackup(m repository.Metadata, cli *client.Client) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *SyncCmd) pull(gameID string, cli *client.Client) error {
|
||||
return p.Service.PullArchive(gameID, "", cli)
|
||||
func (p *SyncCmd) pull(g repository.Metadata, cli *client.Client) error {
|
||||
if err := p.Service.PullArchive(g.ID, "", cli); err != nil {
|
||||
return err
|
||||
}
|
||||
return p.Service.ApplyCurrent(g.ID)
|
||||
}
|
||||
|
||||
func connect(remoteCred map[string]map[string]string, r remote.Remote) (*client.Client, error) {
|
||||
@@ -278,6 +281,9 @@ func connect(remoteCred map[string]map[string]string, r remote.Remote) (*client.
|
||||
return cli, nil
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
fmt.Println("Connexion to", r.URL)
|
||||
fmt.Println("============")
|
||||
username, password, err := credentials.Read()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read std output: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user