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

Function optionalStringInput

src/lib/user-query.ts:50–64  ·  view source on GitHub ↗
(
		message: string,
		options?: OptionalStringInputOptions,
)

Source from the content-addressed store, hash-verified

48}
49
50export const optionalStringInput = async (
51 message: string,
52 options?: OptionalStringInputOptions,
53): Promise<string | undefined> => {
54 const internalOptions = { ...options, required: false }
55 // ensure empty input is allowed regardless of the validator
56 const originalValidate = internalOptions.validate
57 if (originalValidate) {
58 internalOptions.validate = input => !input || originalValidate(input)
59 }
60 const entered = await internalStringInput(message, internalOptions)
61
62 // inquirer returns an empty string when nothing entered; convert that to undefined
63 return entered ? entered : undefined
64}
65
66export type StringInputOptions =
67 & Omit<OptionalStringInputOptions, 'default'>

Callers 10

getInputFromUserFunction · 0.85
promptAndAddAttributeFunction · 0.85
promptAndAddCommandFunction · 0.85
promptAndAddComponentFunction · 0.85
chooseDeviceNameFunction · 0.85
getCommandFromUserFunction · 0.85
buildFromUserInputFunction · 0.85
updateFromUserInputFunction · 0.85
user-query.test.tsFile · 0.85

Calls 1

internalStringInputFunction · 0.85

Tested by

no test coverage detected