How to use the ink.renderToString 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 npm / tink / lib / commands / access.jsx View on Github external
const render = (opts, content = {}) => {
  const { h, renderToString } = require('ink') // eslint-disable-line
  const Table = require('ink-table').default

  if (opts.json) {
    console.log(JSON.stringify(content, null, 2))
  } else if (opts.parseable) {
    console.log(['collaborator', 'access'].join('\t'))
    Object.keys(content).forEach(collab => {
      console.log([collab, content[collab]].join('\t'))
    })
  } else if (!opts.silent && opts.loglevel !== 'silent') {
    const data = Object.keys(content).map(collab => {
      return { collab, role: content[collab] }
    })
    console.log(renderToString())
  }
}
<table></table>
github npm / tink / lib / commands / profile.jsx View on Github external
try {
    const tokens = await libprofile.listTokens(opts)

    if (opts.json) {
      console.log(JSON.stringify(tokens, null, 2))
    } else if (opts.parseable) {
      console.log(tableHeaders.join('\t'))
      tokens.forEach(token =&gt; {
        let values = tableHeaders
          .map(header =&gt; token[header])
          .reduce((previous, current) =&gt; `${previous}\t${current}`)
        console.log(values)
      })
    } else if (!opts.silent &amp;&amp; opts.loglevel !== 'silent') {
      const data = tokens.map(token =&gt; mapTokenToTable(token))
      console.log(renderToString())
    }
  } catch (e) {
    logError(e)
  }
}
<table></table>
github npm / tink / lib / commands / view.js View on Github external
}))
  const { rawSpec } = libnpm.parseArg(spec)

  const options = {
    packument,
    fields,
    spec: rawSpec && rawSpec !== '.' ? rawSpec : null,
    json: opts.json
  }

  try {
    const view = h(
      fields.length ? PackageFields : PackageView,
      options
    )
    console.log(renderToString(view))
  } catch (e) {
    opts.log.error('view', e.message)
    opts.log.error('view', e.stack)
  }
}
github npm / tink / lib / commands / profile.jsx View on Github external
const value = key === 'tfa'
          ? parseTfaInfo(profileInfo[key])
          : profileInfo[key]

        if (value) {
          console.log([key, value].join('\t'))
        }
      })
    } else if (!opts.silent &amp;&amp; opts.loglevel !== 'silent') {
      profileInfo.tfa = parseTfaInfo(profileInfo.tfa)

      const profileTableData = Object.keys(profileInfo).map(k =&gt; ({
        key: k,
        value: profileInfo[k]
      }))
      console.log(renderToString())
    }
  } catch (e) {
    logError(e)
  }
}
<table></table>
github npm / tink / lib / commands / org.jsx View on Github external
async function orgLs (argv, opts) {
  opts = OrgConfig(opts)
  const roster = await orgs.ls(opts.org, opts)
  if (opts.json) {
    console.log(JSON.stringify(roster, null, 2))
  } else if (opts.parseable) {
    console.log(['user', 'role'].join('\t'))
    Object.keys(roster).forEach(user =&gt; {
      console.log([user, roster[user]].join('\t'))
    })
  } else if (!opts.silent &amp;&amp; opts.loglevel !== 'silent') {
    const data = Object.keys(roster).map(user =&gt; {
      return {user, role: roster[user]}
    })
    console.log(renderToString())
  }
}
<table></table>
github npm / tink / lib / commands / profile.jsx View on Github external
argv['read-only'],
    argv.cidr_whitelist,
    opts
  ))

  if (opts.json) {
    console.log(JSON.stringify(newToken, null, 2))
  } else if (opts.parseable) {
    console.log(tableHeaders.join('\t'))
    let values = tableHeaders
      .map(header =&gt; newToken[header])
      .reduce((previous, current) =&gt; `${previous}\t${current}`)
    console.log(values)
  } else if (!opts.silent &amp;&amp; opts.loglevel !== 'silent') {
    const data = [mapTokenToTable(newToken, { trimToken: false })]
    console.log(renderToString())
  }
}
<table></table>
github karaggeorge / ink-scrollbar / src / components / scrollbar.js View on Github external
    const maxLength = Math.max(...this.props.children.map(option => renderToString(option).length));
github karaggeorge / ink-scrollbar / src / components / scrollbar.js View on Github external
getSpacing(option) {
    return '\u00A0'.repeat(this.state.maxLength - renderToString(option).length + this.props.padding);
  }

ink

React for CLI

MIT
Latest version published 8 months ago

Package Health Score

85 / 100
Full package analysis