From 9962827926d6a63aac2ef7f63ae7e974589f4cdb Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Wed, 9 Nov 2016 00:39:39 +0300 Subject: [PATCH] add sync command to synchronize yanked/deleted files with server Mentioned in #13 and #36. --- comp.go | 1 + doc.go | 1 + docstring.go | 1 + eval.go | 12 ++++++++++++ 4 files changed, 15 insertions(+) diff --git a/comp.go b/comp.go index e746906..da1a639 100644 --- a/comp.go +++ b/comp.go @@ -37,6 +37,7 @@ var ( "delete", "put", "renew", + "sync", "echo", "cd", "push", diff --git a/doc.go b/doc.go index be5b6cd..7d035aa 100644 --- a/doc.go +++ b/doc.go @@ -38,6 +38,7 @@ The following commands are provided by lf with default keybindings. The following commands are provided by lf without default keybindings. + sync synchronizes yanked/deleted files with server echo prints its arguments to the message line cd changes working directory to its argument push simulate key pushes given in its argument diff --git a/docstring.go b/docstring.go index 16d6c0f..f0b69db 100644 --- a/docstring.go +++ b/docstring.go @@ -42,6 +42,7 @@ The following commands are provided by lf with default keybindings. The following commands are provided by lf without default keybindings. + sync synchronizes yanked/deleted files with server echo prints its arguments to the message line cd changes working directory to its argument push simulate key pushes given in its argument diff --git a/eval.go b/eval.go index a1efc49..fbddbc7 100644 --- a/eval.go +++ b/eval.go @@ -325,6 +325,18 @@ func (e *CallExpr) eval(app *App, args []string) { app.ui.sync() app.ui.renew() app.nav.renew(app.ui.wins[0].h) + case "sync": + list, copy, err := loadFiles() + if err != nil { + msg := fmt.Sprintf("sync: %s", err) + app.ui.message = msg + log.Printf(msg) + return + } + app.nav.saves = make(map[string]bool) + for _, f := range list { + app.nav.saves[f] = copy + } case "echo": app.ui.message = strings.Join(e.args, " ") case "cd":