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

Function handleDateProcess

packages/effect/src/unstable/cli/Prompt.ts:1718–1756  ·  view source on GitHub ↗
(options: DateOptionsReq)

Source from the content-addressed store, hash-verified

1716}
1717
1718const handleDateProcess = (options: DateOptionsReq) => {
1719 return (input: Terminal.UserInput, state: DateState) => {
1720 switch (input.key.name) {
1721 case "left": {
1722 return Effect.succeed(processDateCursorLeft(state))
1723 }
1724 case "right": {
1725 return Effect.succeed(processDateCursorRight(state))
1726 }
1727 case "k":
1728 case "up": {
1729 return Effect.succeed(processUp(state))
1730 }
1731 case "j":
1732 case "down": {
1733 return Effect.succeed(processDown(state))
1734 }
1735 case "tab": {
1736 return Effect.succeed(processDateNext(state))
1737 }
1738 case "enter":
1739 case "return": {
1740 return Effect.match(options.validate(state.value), {
1741 onFailure: (error) =>
1742 Action.NextFrame({
1743 state: {
1744 ...state,
1745 error: Option.some(error)
1746 }
1747 }),
1748 onSuccess: (value) => Action.Submit({ value })
1749 })
1750 }
1751 default: {
1752 return Effect.succeed(defaultDateProcessor(Option.getOrElse(input.input, () => ""), state))
1753 }
1754 }
1755 }
1756}
1757
1758const DATE_PART_REGEXP =
1759 /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g

Callers 1

dateFunction · 0.85

Calls 8

processDateCursorLeftFunction · 0.85
processDateCursorRightFunction · 0.85
processUpFunction · 0.85
processDownFunction · 0.85
processDateNextFunction · 0.85
defaultDateProcessorFunction · 0.85
someMethod · 0.80
succeedMethod · 0.45

Tested by

no test coverage detected