From 6c319316e24c8214d17b41391c7cb83e8a33483c Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Thu, 28 Jun 2018 17:13:43 +0300 Subject: [PATCH] add 'source' command to read a configuration file Related #97 --- complete.go | 1 + doc.go | 1 + docstring.go | 1 + eval.go | 6 ++++++ 4 files changed, 9 insertions(+) diff --git a/complete.go b/complete.go index e688b54..484839d 100644 --- a/complete.go +++ b/complete.go @@ -49,6 +49,7 @@ var ( "echo", "cd", "select", + "source", "push", } diff --git a/doc.go b/doc.go index a2a1ef1..676190e 100644 --- a/doc.go +++ b/doc.go @@ -50,6 +50,7 @@ The following commands are provided by lf without default keybindings: echo prints its arguments to the message line cd changes working directory to its argument select changes current file selection to its argument + source reads the configuration file in its argument push simulate key pushes given in its argument The following command line commands are provided by lf with default diff --git a/docstring.go b/docstring.go index 22086ae..ef9a751 100644 --- a/docstring.go +++ b/docstring.go @@ -54,6 +54,7 @@ The following commands are provided by lf without default keybindings: echo prints its arguments to the message line cd changes working directory to its argument select changes current file selection to its argument + source reads and evaluates the file in its argument push simulate key pushes given in its argument The following command line commands are provided by lf with default diff --git a/eval.go b/eval.go index 29f5c83..1db946b 100644 --- a/eval.go +++ b/eval.go @@ -464,6 +464,12 @@ func (e *callExpr) eval(app *app, args []string) { } app.ui.loadFile(app.nav) app.ui.loadFileInfo(app.nav) + case "source": + if len(e.args) != 1 { + app.ui.print("source: requires an argument") + return + } + app.readFile(strings.Replace(e.args[0], "~", gUser.HomeDir, -1)) case "push": if len(e.args) != 1 { app.ui.print("push: requires an argument")