Skip to content

Instantly share code, notes, and snippets.

@samuelloza
Forked from AnishDe12020/cli.js
Created October 11, 2022 02:24
Show Gist options
  • Save samuelloza/784fdf257da0cf1ae933c3dc46a2d3b7 to your computer and use it in GitHub Desktop.
Save samuelloza/784fdf257da0cf1ae933c3dc46a2d3b7 to your computer and use it in GitHub Desktop.
Medium - Getting Started with React Ink
#!/usr/bin/env node
'use strict';
const React = require('react');
const importJsx = require('import-jsx');
const {render} = require('ink');
const meow = require('meow');
const ui = importJsx('./ui');
const cli = meow(`
Usage
$ sandbox
Options
 - name Your name
Examples
$ sandbox - name=Jane
Hello, Jane
`);
render(React.createElement(ui, cli.flags));
'use strict';
const React = require('react');
const {Text} = require('ink');
const App = ({name = 'Stranger'}) => (
<Text>
Hello, <Text color="green">{name}</Text>
</Text>
);
module.exports = App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment