ink-cli-parser
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

ink-cli-parser

GitHub license GitHub license DeepScan grade npm

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 />);

ss


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
}

Readme

Keywords

none

Package Sidebar

Install

npm i ink-cli-parser

Weekly Downloads

2

Version

2.0.0

License

ISC

Unpacked Size

38.6 kB

Total Files

42

Last publish

Collaborators

  • souvik210899