# CLI

`ng-state` has optional package `ng-state-cli` which makes developers lives easier by generating new files or integrating state management to existing ones.

Install it from npm

```
npm install ng-state-cli -g
```

In terminal type `ngstate` and answer couple questions:

1. Name of the component - e.g: `todos`
2. Choose directory
3. Enter state path like you do in `@InjectStore` decorator - e.g: `['todos', '${stateIndex}']` or '`todos'`&#x20;
4. Chose `Add` or `Append`&#x20;

When `Add` is chosen `ng-state-cli` will generate these files

* actions
* component
* html template
* styles
* spec

![](https://2483127471-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La0zIK2BFiXY6Eig7aR%2F-Lbvfx4w_Ayn-VWIE3x-%2F-LbvgBo-KuSplREXp7a4%2Fngstatecligenerate2.gif?alt=media\&token=90b76044-6d74-43ae-86a4-2a236636c1c7)

When `Append` is chosen `ng-state-cli` will do following

* generate action
* modify component file
* modify spec file

*Append plays nice with angular cli*

![](https://2483127471-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La0zIK2BFiXY6Eig7aR%2F-Lbvfx4w_Ayn-VWIE3x-%2F-LbvgFP2IpIRr0Ei2Lyl%2Fngstatecliappend.gif?alt=media\&token=e6653173-1930-473d-a3e2-ba0adc5e32dd)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vytautas.gitbook.io/ng-state/other-information/cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
