-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2763fc
commit a49b074
Showing
2 changed files
with
44 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
import React from 'react'; | ||
import {Text} from 'ink'; | ||
|
||
export default function App({name = 'Stranger'}) { | ||
return ( | ||
<Text> | ||
Hello, <Text color="green">{name}</Text>? nice to meet you. | ||
</Text> | ||
); | ||
} | ||
import { Box, Text } from 'ink'; | ||
import Enquirer from 'enquirer'; | ||
|
||
const App = () => { | ||
const [name, setName] = React.useState(); | ||
|
||
React.useEffect(() => { | ||
const enquirer = new Enquirer(); | ||
enquirer | ||
.prompt({ | ||
type: 'input', | ||
name: 'username', | ||
message: 'What is your name?' | ||
}) | ||
.then(answer => setName(answer.username)); | ||
}, []); | ||
|
||
|
||
return name ? ( | ||
<Box> | ||
<Text>Hello, {name}!</Text> | ||
</Box> | ||
) : ( | ||
<Box> | ||
<Text>Welcome to our CLI App. Please input your name.</Text> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
#!/usr/bin/env node | ||
import React from 'react'; | ||
import {render} from 'ink'; | ||
import { render } from 'ink'; | ||
import meow from 'meow'; | ||
import App from './app.js'; | ||
|
||
const cli = meow( | ||
` | ||
Usage | ||
$ up-date-cli | ||
` | ||
Usage | ||
$ up-date | ||
Options | ||
--name Your name | ||
Options | ||
--name Your name | ||
Examples | ||
$ up-date-cli --name=Jane | ||
Hello, Jane | ||
`, | ||
{ | ||
importMeta: import.meta, | ||
}, | ||
Examples | ||
$ up-date --name=Jane | ||
Hello, Jane | ||
`, | ||
{ | ||
importMeta: import.meta, | ||
} | ||
); | ||
|
||
render(<App name={cli.flags.name} />); | ||
render(<App />); |