MCPcopy
hub / github.com/dbcli/pgcli / run_cli

Method run_cli

pgcli/main.py:959–1009  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

957 return query.successful # quit only if query is successful
958
959 def run_cli(self):
960 logger = self.logger
961
962 history_file = self.config["main"]["history_file"]
963 if history_file == "default":
964 history_file = config_location() + "history"
965 history = FileHistory(os.path.expanduser(history_file))
966 self.refresh_completions(history=history, persist_priorities="none")
967
968 self.prompt_app = self._build_cli(history)
969
970 if not self.less_chatty:
971 print("Server: PostgreSQL", self.pgexecute.server_version)
972 print("Version:", __version__)
973 print("Home: https://pgcli.com")
974
975 try:
976 while True:
977 try:
978 text = self.prompt_app.prompt()
979 except KeyboardInterrupt:
980 continue
981 except EOFError:
982 if not self._check_ongoing_transaction_and_allow_quitting():
983 continue
984 raise
985
986 try:
987 text = self.handle_editor_command(text)
988 except RuntimeError as e:
989 logger.error("sql: %r, error: %r", text, e)
990 logger.error("traceback: %r", traceback.format_exc())
991 click.secho(str(e), err=True, fg="red")
992 continue
993
994 try:
995 self.handle_watch_command(text)
996 except PgCliQuitError:
997 if not self._check_ongoing_transaction_and_allow_quitting():
998 continue
999 raise
1000
1001 self.now = dt.datetime.today()
1002
1003 # Allow PGCompleter to learn user's preferred keywords, etc.
1004 with self._completer_lock:
1005 self.completer.extend_query_history(text)
1006
1007 except (PgCliQuitError, EOFError):
1008 if not self.less_chatty:
1009 print("Goodbye!")
1010
1011 def handle_watch_command(self, text):
1012 # Initialize default metaquery in case execution fails

Callers 6

pgcli_line_magicFunction · 0.95
cliFunction · 0.95
before_scenarioFunction · 0.80
step_run_cli_with_argFunction · 0.80
step_run_cliFunction · 0.80
step_run_cli_using_argFunction · 0.80

Calls 7

refresh_completionsMethod · 0.95
_build_cliMethod · 0.95
handle_editor_commandMethod · 0.95
handle_watch_commandMethod · 0.95
config_locationFunction · 0.85
extend_query_historyMethod · 0.80

Tested by

no test coverage detected