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

Function handleDateProcess

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

Source from the content-addressed store, hash-verified

1878}
1879
1880const handleDateProcess = (options: DateOptionsReq) => {
1881 return (input: Terminal.UserInput, state: DateState) => {
1882 switch (input.key.name) {
1883 case "left": {
1884 return Effect.succeed(processDateCursorLeft(state))
1885 }
1886 case "right": {
1887 return Effect.succeed(processDateCursorRight(state))
1888 }
1889 case "k":
1890 case "up": {
1891 return Effect.succeed(processUp(state))
1892 }
1893 case "j":
1894 case "down": {
1895 return Effect.succeed(processDown(state))
1896 }
1897 case "tab": {
1898 return Effect.succeed(processDateNext(state))
1899 }
1900 case "enter":
1901 case "return": {
1902 return Effect.match(options.validate(state.value), {
1903 onFailure: (error) =>
1904 Action.NextFrame({
1905 state: {
1906 ...state,
1907 error: Option.some(error)
1908 }
1909 }),
1910 onSuccess: (value) => Action.Submit({ value })
1911 })
1912 }
1913 default: {
1914 return Effect.succeed(defaultDateProcessor(Option.getOrElse(input.input, () => ""), state))
1915 }
1916 }
1917 }
1918}
1919
1920const DATE_PART_REGEXP =
1921 /\\(.)|"((?:\\["\\]|[^"])+)"|(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 9

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

Tested by

no test coverage detected