diff options
author | Amjith Ramanujam <amjith.r@gmail.com> | 2018-11-29 20:41:24 -0800 |
---|---|---|
committer | Amjith Ramanujam <amjith.r@gmail.com> | 2018-11-29 20:41:24 -0800 |
commit | bea19ee7ca63532d8a87b15c04ce816903357499 (patch) | |
tree | 41b9406fcbe7bdd39b14482236725375a0851119 | |
parent | e33f07ce3acc011fdcf2ca38c3a9a8c06cec5044 (diff) |
Add some convenience aliases.
-rwxr-xr-x | litecli/main.py | 6 | ||||
-rw-r--r-- | litecli/packages/special/dbcommands.py | 2 | ||||
-rw-r--r-- | litecli/sqlexecute.py | 6 |
3 files changed, 12 insertions, 2 deletions
diff --git a/litecli/main.py b/litecli/main.py index 3ab8bbd..f7c12a6 100755 --- a/litecli/main.py +++ b/litecli/main.py @@ -142,7 +142,11 @@ class LiteCli(object): def register_special_commands(self): special.register_special_command( - self.change_db, ".open", ".open", "Change to a new database." + self.change_db, + ".open", + ".open", + "Change to a new database.", + aliases=("use", "\\u"), ) special.register_special_command( self.refresh_completions, diff --git a/litecli/packages/special/dbcommands.py b/litecli/packages/special/dbcommands.py index 026f4a1..67dc769 100644 --- a/litecli/packages/special/dbcommands.py +++ b/litecli/packages/special/dbcommands.py @@ -60,6 +60,7 @@ def list_tables(cur, arg=None, arg_type=PARSED_QUERY, verbose=False): "The complete schema for the database or a single table", arg_type=PARSED_QUERY, case_sensitive=True, + aliases=("\\d",), ) def show_schema(cur, arg=None, **_): if arg: @@ -94,6 +95,7 @@ def show_schema(cur, arg=None, **_): "List databases.", arg_type=RAW_QUERY, case_sensitive=True, + aliases=("\\l",), ) def list_databases(cur, **_): query = "PRAGMA database_list" diff --git a/litecli/sqlexecute.py b/litecli/sqlexecute.py index 057c72d..0d6bc8c 100644 --- a/litecli/sqlexecute.py +++ b/litecli/sqlexecute.py @@ -92,7 +92,11 @@ class SQLExecute(object): special.set_expanded_output(True) sql = sql[:-2].strip() - if not self.conn and not sql.startswith(".open"): + if not self.conn and not ( + sql.startswith(".open") + or sql.lower().startswith("use") + or sql.startswith("\\u") + ): _logger.debug( "Not connected to database. Will not run statement: %s.", sql ) |