How to use the ink.useStdin function in ink

To help you get started, we’ve selected a few ink examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prisma / prisma2 / cli / ink-components / src / hooks / useStdin.ts View on Github external
export function useStdin(
  keyHandler: ({ actionKey: ActionKey, text: string, key: Key }) => void,
  deps: any[] = [],
) {
  let { stdin, setRawMode } = inkUseStdin()

  // stdin = stdin || process.stdin
  // setRawMode = setRawMode || process.stdin.setRawMode

  emitKeypressEvents(stdin)

  let didCancel = false

  React.useEffect(() => {
    function handler(text: string, key: Key) {
      if (!didCancel) {
        keyHandler({ actionKey: action(key), text, key })
      }
    }

    setRawMode!(true)

ink

React for CLI

MIT
Latest version published 5 months ago

Package Health Score

93 / 100
Full package analysis