MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / ask

Method ask

uncommon_route/onboarding.py:70–96  ·  view source on GitHub ↗
(
        self,
        prompt: str,
        *,
        default: str = "",
        secret: bool = False,
        allow_empty: bool = False,
    )

Source from the content-addressed store, hash-verified

68 self.stdout.write("Please answer y or n.\n")
69
70 def ask(
71 self,
72 prompt: str,
73 *,
74 default: str = "",
75 secret: bool = False,
76 allow_empty: bool = False,
77 ) -> str:
78 while True:
79 display_default = f" [{default}]" if default else ""
80 full_prompt = f"{prompt}{display_default}: "
81 if secret and self._interactive:
82 answer = getpass.getpass(full_prompt)
83 else:
84 self.stdout.write(full_prompt)
85 self.stdout.flush()
86 answer = self.stdin.readline()
87 if answer == "":
88 answer = ""
89 else:
90 answer = answer.rstrip("\n")
91 clean = answer.strip()
92 if not clean and default:
93 clean = default
94 if clean or allow_empty:
95 return clean
96 self.stdout.write("This value is required.\n")
97
98 def _choose_numbered(
99 self,

Callers 1

_cmd_initFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected