MCPcopy Create free account
hub / github.com/dbcli/mssql-cli / _build_cli

Method _build_cli

mssqlcli/mssql_cli.py:453–514  ·  view source on GitHub ↗

Builds prompt session. NOTE: PROMPT-SESSION USES THIS AS DEPENDENCY.

(self, history)

Source from the content-addressed store, hash-verified

451 print(localized.goodbye())
452
453 def _build_cli(self, history):
454 """
455 Builds prompt session.
456 NOTE: PROMPT-SESSION USES THIS AS DEPENDENCY.
457 """
458
459 def get_message():
460 prompt = self.get_prompt(self.prompt_format)
461 return [(u'class:prompt', prompt)]
462
463 def get_continuation(width, line_number, is_soft_wrap):
464 """
465 NOTE: updating parameters will cause prompt session to crash.
466 """
467 # pylint: disable=unused-argument
468 continuation = self.multiline_continuation_char * (width - 1) + ' '
469 return [(u'class:continuation', continuation)]
470
471 get_toolbar_tokens = create_toolbar_tokens_func(self)
472
473 if self.wider_completion_menu:
474 complete_style = CompleteStyle.MULTI_COLUMN
475 else:
476 complete_style = CompleteStyle.COLUMN
477
478 with self._completer_lock:
479 self.prompt_session = PromptSession(
480 message=get_message,
481 style=style_factory(self.syntax_style, self.cli_style),
482
483 # Layout options.
484 lexer=PygmentsLexer(PostgresLexer),
485 prompt_continuation=get_continuation,
486 bottom_toolbar=get_toolbar_tokens,
487 complete_style=complete_style,
488 input_processors=[
489 ConditionalProcessor(
490 processor=HighlightMatchingBracketProcessor(
491 chars='[](){}'),
492 #pylint: disable=invalid-unary-operand-type
493 filter=HasFocus(DEFAULT_BUFFER) & ~IsDone()),
494 # Render \t as 4 spaces instead of "^I"
495 TabsProcessor(char1=u' ', char2=u' ')],
496 reserve_space_for_menu=self.min_num_menu_lines,
497
498 # Buffer options.
499 multiline=mssql_is_multiline(self),
500 completer=ThreadedCompleter(
501 DynamicCompleter(lambda: self.completer)),
502 history=history, auto_suggest=AutoSuggestFromHistory(),
503 complete_while_typing=True,
504
505 # Key bindings.
506 enable_system_prompt=True,
507 enable_open_in_editor=True,
508
509 # Other options.
510 key_bindings=mssqlcli_bindings(self),

Callers 1

runMethod · 0.95

Calls 4

style_factoryFunction · 0.90
mssql_is_multilineFunction · 0.90
mssqlcli_bindingsFunction · 0.90

Tested by

no test coverage detected