summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2019-08-17 05:56:45 -0700
committerGitHub <noreply@github.com>2019-08-17 05:56:45 -0700
commitfbcd425001a2367d92cc611abf28d46258395b55 (patch)
tree8f358766fe374352a1af84ac620d16518ee52031
parentc7947e9bfd06cf39fa0b4839d9831ae055c170a1 (diff)
parent471525694175e229b7dba3e96293c8e5607e9240 (diff)
Merge pull request #71 from shwnchpl/read-command
Add .read command
-rw-r--r--changelog.md1
-rw-r--r--litecli/AUTHORS1
-rw-r--r--litecli/packages/special/dbcommands.py18
3 files changed, 20 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index b35faec..c3f54fe 100644
--- a/changelog.md
+++ b/changelog.md
@@ -23,6 +23,7 @@ Bug Fixes:
Features:
---------
+* Added `.read` command for reading scripts.
* Added `.load` command for loading extension libraries. (Thanks: [Zhiming Wang])
* Add support for using `?` as a placeholder in the favorite queries. (Thanks: [Amjith])
* Added shift-tab to select the previous entry in the completion menu. [Amjith]
diff --git a/litecli/AUTHORS b/litecli/AUTHORS
index 073f137..d5265de 100644
--- a/litecli/AUTHORS
+++ b/litecli/AUTHORS
@@ -17,3 +17,4 @@ Contributors:
* Thomas Roten
* Zhaolong Zhu
* Zhiming Wang
+ * Shawn M. Chapla
diff --git a/litecli/packages/special/dbcommands.py b/litecli/packages/special/dbcommands.py
index eefe7e6..bd9f0fd 100644
--- a/litecli/packages/special/dbcommands.py
+++ b/litecli/packages/special/dbcommands.py
@@ -168,3 +168,21 @@ def load_extension(cur, arg, **_):
conn.enable_load_extension(True)
conn.load_extension(path)
return [(None, None, None, "")]
+
+
+@special_command(
+ ".read",
+ ".read path",
+ "Read input from path",
+ arg_type=PARSED_QUERY,
+ case_sensitive=True,
+)
+def read_script(cur, arg, **_):
+ args = shlex.split(arg)
+ if len(args) != 1:
+ raise TypeError(".read accepts exactly one path")
+ path = args[0]
+ with open(path, "r") as f:
+ script = f.read()
+ cur.executescript(script)
+ return [(None, None, None, "")]