MCPcopy Create free account
hub / github.com/Effect-TS/effect / Int

Function Int

packages/effect/src/cli/Prompt.ts:1166–1195  ·  view source on GitHub ↗
(options: IntOptions)

Source from the content-addressed store, hash-verified

1164 * @since 4.0.0
1165 */
1166export const Int = (options: IntOptions): Prompt<number> => {
1167 const opts: IntOptionsReq = {
1168 default: 0,
1169 min: globalThis.Number.NEGATIVE_INFINITY,
1170 max: globalThis.Number.POSITIVE_INFINITY,
1171 incrementBy: 1,
1172 decrementBy: 1,
1173 validate: (n) => {
1174 if (n < opts.min) {
1175 return Effect.fail(`${n} must be greater than or equal to ${opts.min}`)
1176 }
1177 if (n > opts.max) {
1178 return Effect.fail(`${n} must be less than or equal to ${opts.max}`)
1179 }
1180 return Effect.succeed(n)
1181 },
1182 ...options
1183 }
1184 const initialValue = options.default === undefined ? "" : `${opts.default}`
1185 const initialState: NumberState = {
1186 cursor: initialValue.length,
1187 value: initialValue,
1188 error: Option.none()
1189 }
1190 return Custom(initialState, {
1191 render: handleRenderInteger(opts),
1192 process: handleProcessInteger(opts),
1193 clear: handleNumberClear(opts)
1194 })
1195}
1196
1197/**
1198 * Creates a text prompt that returns an array of strings by splitting the

Callers

nothing calls this directly

Calls 6

handleRenderIntegerFunction · 0.85
handleProcessIntegerFunction · 0.85
handleNumberClearFunction · 0.85
CustomFunction · 0.70
failMethod · 0.65
succeedMethod · 0.45

Tested by

no test coverage detected