MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / read_secret

Method read_secret

cmd2/cmd2.py:3576–3592  ·  view source on GitHub ↗

Read a secret from stdin without displaying the value on the screen. :param prompt: prompt to display to user :return: the secret read from stdin with all trailing new lines removed :raises EOFError: if the input stream is closed or the user signals EOF (e.g., Ctrl+D)

(
        self,
        prompt: str = "",
    )

Source from the content-addressed store, hash-verified

3574 return self._read_raw_input(prompt, temp_session)
3575
3576 def read_secret(
3577 self,
3578 prompt: str = "",
3579 ) -> str:
3580 """Read a secret from stdin without displaying the value on the screen.
3581
3582 :param prompt: prompt to display to user
3583 :return: the secret read from stdin with all trailing new lines removed
3584 :raises EOFError: if the input stream is closed or the user signals EOF (e.g., Ctrl+D)
3585 :raises Exception: any other exceptions raised by prompt()
3586 """
3587 temp_session: PromptSession[str] = PromptSession(
3588 input=self.main_session.input,
3589 output=self.main_session.output,
3590 )
3591
3592 return self._read_raw_input(prompt, temp_session, is_password=True)
3593
3594 def _process_alerts(self) -> None:
3595 """Background worker that processes queued alerts and dynamic prompt updates."""

Callers 3

test_read_secretFunction · 0.80
test_read_secret_eofFunction · 0.80
do_read_passwordMethod · 0.80

Calls 1

_read_raw_inputMethod · 0.95

Tested by 2

test_read_secretFunction · 0.64
test_read_secret_eofFunction · 0.64