MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / internalStringInput

Function internalStringInput

src/lib/user-query.ts:26–48  ·  view source on GitHub ↗
(
		message: string,
		options: OptionalStringInputOptions & { required: boolean },
)

Source from the content-addressed store, hash-verified

24 helpText?: string
25}
26const internalStringInput = async (
27 message: string,
28 options: OptionalStringInputOptions & { required: boolean },
29): Promise<string> => {
30 const optValidate = options.validate
31 const validate = (options?.helpText && optValidate)
32 ? (input: string) => input === '?' || optValidate(input)
33 : optValidate
34 const question = {
35 message: options?.helpText ? `${message} (? for help)` : message,
36 default: typeof options?.default === 'function' ? options.default() : options?.default,
37 validate,
38 required: options.required,
39 }
40
41 let entered = await input(question)
42 while (options?.helpText && entered === '?') {
43 console.log(options.helpText)
44 entered = await input(question)
45 }
46
47 return entered
48}
49
50export const optionalStringInput = async (
51 message: string,

Callers 2

optionalStringInputFunction · 0.85
stringInputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected