ink-cli-parser v2.0.0
ink-cli-parser
ink-cli-parser is a cli parser tool that is built just for ink. You can pass in you custom ink help component and error component.
Table Of Contents
Getting Started
To install ink-cli-parser
, ensure that you have Node.js >=10.
Install nodejs from here
Installation
The easiest way to install ink-cli-parser
is using NPM. If you have Node.js
installed, it is most likely that you have NPM installed as well
$ npm install ink-cli-parser
Usage
import React, { FC } from "react";
import { Router, Switch, Command } from "ink-cli-router";
import { render, Text } from "ink";
const Create = () => {
return <Text>{"Creating file"}</Text>;
};
const App: FC<{ any }> = () => {
return (
<Router argv={process.argv}>
<Switch>
<Command name="create" component={<Create />} />
</Switch>
</Router>
);
};
render(<App />);
Api Reference
Components
<Router>
A <Router>
that uses react context to keep the UI sync with the CLI argument
and falgs
argv
: string[] name
?: string description
?: string
autoHelp
?: boolean
<Switch>
Renders only the command and flags that match the CLI arguments
<Command>
name
: string description
?: string component
?: React.ReactElement
<Flags>
name
: string alias
: string component
?: React.ReactElement
description
?: string
Hooks
useCli
Use this hook to get the CLI arguments
returns
{
command: string | undefined
arguments: string[] | undefined
flags: any
}