MCPcopy
hub / github.com/Effect-TS/effect / wizardInternal

Function wizardInternal

packages/cli/src/internal/primitive.ts:544–619  ·  view source on GitHub ↗
(self: Instruction, help: HelpDoc.HelpDoc)

Source from the content-addressed store, hash-verified

542}
543
544const wizardInternal = (self: Instruction, help: HelpDoc.HelpDoc): Prompt.Prompt<any> => {
545 switch (self._tag) {
546 case "Bool": {
547 const primitiveHelp = InternalHelpDoc.p("Select true or false")
548 const message = InternalHelpDoc.sequence(help, primitiveHelp)
549 const initial = Option.getOrElse(self.defaultValue, () => false)
550 return InternalTogglePrompt.toggle({
551 message: InternalHelpDoc.toAnsiText(message).trimEnd(),
552 initial,
553 active: "true",
554 inactive: "false"
555 }).pipe(InternalPrompt.map((bool) => `${bool}`))
556 }
557 case "Choice": {
558 const primitiveHelp = InternalHelpDoc.p("Select one of the following choices")
559 const message = InternalHelpDoc.sequence(help, primitiveHelp)
560 return InternalSelectPrompt.select({
561 message: InternalHelpDoc.toAnsiText(message).trimEnd(),
562 choices: Arr.map(
563 self.alternatives,
564 ([title]) => ({ title, value: title })
565 )
566 })
567 }
568 case "DateTime": {
569 const primitiveHelp = InternalHelpDoc.p("Enter a date")
570 const message = InternalHelpDoc.sequence(help, primitiveHelp)
571 return InternalDatePrompt.date({
572 message: InternalHelpDoc.toAnsiText(message).trimEnd()
573 }).pipe(InternalPrompt.map((date) => date.toISOString()))
574 }
575 case "Float": {
576 const primitiveHelp = InternalHelpDoc.p("Enter a floating point value")
577 const message = InternalHelpDoc.sequence(help, primitiveHelp)
578 return InternalNumberPrompt.float({
579 message: InternalHelpDoc.toAnsiText(message).trimEnd()
580 }).pipe(InternalPrompt.map((value) => `${value}`))
581 }
582 case "Integer": {
583 const primitiveHelp = InternalHelpDoc.p("Enter an integer")
584 const message = InternalHelpDoc.sequence(help, primitiveHelp)
585 return InternalNumberPrompt.integer({
586 message: InternalHelpDoc.toAnsiText(message).trimEnd()
587 }).pipe(InternalPrompt.map((value) => `${value}`))
588 }
589 case "Path": {
590 const primitiveHelp = InternalHelpDoc.p("Select a file system path")
591 const message = InternalHelpDoc.sequence(help, primitiveHelp)
592 return InternalFilePrompt.file({
593 type: self.pathType,
594 message: InternalHelpDoc.toAnsiText(message).trimEnd()
595 })
596 }
597 case "Redacted": {
598 const primitiveHelp = InternalHelpDoc.p("Enter some text (value will be redacted)")
599 const message = InternalHelpDoc.sequence(help, primitiveHelp)
600 return InternalTextPrompt.hidden({
601 message: InternalHelpDoc.toAnsiText(message).trimEnd()

Callers 1

primitive.tsFile · 0.70

Calls 4

integerMethod · 0.80
pipeMethod · 0.65
mapMethod · 0.65
textMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…