# @codedungeon/gunner

> Node CLI Framework

Latest version **0.80.1** (published 2023-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @codedungeon/gunner
pnpm add @codedungeon/gunner
yarn add @codedungeon/gunner
bun add @codedungeon/gunner
```

Provides the command `gunner`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.80.1 |
| Published | 2023-06-25 |
| First published | 2019-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12.15.0 |
| Dependencies | 47 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 (+9 in 6 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Mike Erickson |
| Maintainers | codedungeon |
| Keywords | cli, codedungeon, framework, javascript, node, starter, skeleton |

## Links

- npm: https://www.npmjs.com/package/@codedungeon/gunner
- Repository: https://github.com/mikeerickson/gunner
- Homepage: https://github.com/mikeerickson/gunner#readme
- Issues: https://github.com/mikeerickson/gunner/issues
- npm.io page: https://npm.io/package/@codedungeon/gunner

## Dependencies (47)

- [ip](https://npm.io/package/ip.md) 1.1.5
- [arg](https://npm.io/package/arg.md) 5.0.0
- [eta](https://npm.io/package/eta.md) 1.12.3
- [ora](https://npm.io/package/ora.md) 5.3.0
- [voca](https://npm.io/package/voca.md) 1.4.0
- [begoo](https://npm.io/package/begoo.md) 1.1.2
- [chalk](https://npm.io/package/chalk.md) 4.1.2
- [dayjs](https://npm.io/package/dayjs.md) 1.10.6
- [execa](https://npm.io/package/execa.md) 5.0.0
- [trash](https://npm.io/package/trash.md) 7.2.0
- [which](https://npm.io/package/which.md) 2.0.2
- [bcrypt](https://npm.io/package/bcrypt.md) 5.0.1
- [pkg-up](https://npm.io/package/pkg-up.md) 3.1.0
- [semver](https://npm.io/package/semver.md) 7.3.5
- [min-dot](https://npm.io/package/min-dot.md) 0.1.1
- [node-ip](https://npm.io/package/node-ip.md) 0.1.2
- [shelljs](https://npm.io/package/shelljs.md) 0.8.4
- [apisauce](https://npm.io/package/apisauce.md) 2.1.1
- [dashdash](https://npm.io/package/dashdash.md) 2.0.0
- [dot-prop](https://npm.io/package/dot-prop.md) 6.0.1
- [enquirer](https://npm.io/package/enquirer.md) 2.3.6
- [fs-chmod](https://npm.io/package/fs-chmod.md) 1.0.6
- [fs-extra](https://npm.io/package/fs-extra.md) 9.1.0
- [jsonfile](https://npm.io/package/jsonfile.md) 6.1.0
- [minimist](https://npm.io/package/minimist.md) 1.2.5
- [mustache](https://npm.io/package/mustache.md) 4.2.0
- [dumper.js](https://npm.io/package/dumper.js.md) 1.3.1
- [npm-which](https://npm.io/package/npm-which.md) 3.0.1
- [pluralize](https://npm.io/package/pluralize.md) 8.0.0
- [ansi-regex](https://npm.io/package/ansi-regex.md) 4.1.0
- [bump-regex](https://npm.io/package/bump-regex.md) 4.1.0
- [cli-table3](https://npm.io/package/cli-table3.md) 0.6.0
- [clipboardy](https://npm.io/package/clipboardy.md) 2.3.0
- [fs-jetpack](https://npm.io/package/fs-jetpack.md) 4.1.1
- [strip-ansi](https://npm.io/package/strip-ansi.md) 5.0.0
- [configstore](https://npm.io/package/configstore.md) 5.0.1
- [read-pkg-up](https://npm.io/package/read-pkg-up.md) 8.0.0
- [git-user-info](https://npm.io/package/git-user-info.md) 1.0.1
- [git-user-local](https://npm.io/package/git-user-local.md) 1.0.0
- [valid-filename](https://npm.io/package/valid-filename.md) 3.1.0
- [github-username](https://npm.io/package/github-username.md) 6.0.0
- [update-notifier](https://npm.io/package/update-notifier.md) 5.1.0
- [fs-extra-promise](https://npm.io/package/fs-extra-promise.md) 1.0.1
- [clear-any-console](https://npm.io/package/clear-any-console.md) 1.16.2
- [@codedungeon/utils](https://npm.io/package/@codedungeon/utils.md) 0.0.12
- [please-upgrade-node](https://npm.io/package/please-upgrade-node.md) 3.2.0
- [@codedungeon/messenger](https://npm.io/package/@codedungeon/messenger.md) 0.14.1

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.80.1 (latest) — 2023-06-25
- 0.79.0 — 2022-08-11
- 0.78.0 — 2022-06-10
- 0.77.0 — 2022-06-09
- 0.76.0 — 2022-02-19
- 0.75.2 — 2022-02-12
- 0.75.1 — 2022-02-12
- 0.75.0 — 2022-02-06
- 0.74.4 — 2021-12-10
- 0.74.2 — 2021-11-17
- 0.74.1 — 2021-11-17
- 0.74.0 — 2021-09-25
- 0.73.0 — 2021-09-10
- 0.72.0 — 2021-09-09
- 0.71.0 — 2021-09-06
- … 106 more at https://npm.io/package/@codedungeon/gunner/versions

## README

<h4 align="center">
    <img src="docs/images/logo-transparent.png" width="10%" height="10%" alt="Gunner Prompts">
</h4>

# Gunner

## Description

**NodeJS CLI Framework**
_created in memory of my trusty sidekick "Gunner" who passed away in 2019, his memory will last in my heart forever._

## Installation (Globally)

Use gunner globally to create new CLI projects (using `gunner new...`) or for creating new commands (`gunner make:command xxx`) and extensions (`gunner make:extension xxx`)

Using npm

```bash
> npm install -g @codedungeon/gunner
```

Using yarn

```bash
> yarn add global @codedungeon/gunner
```

## Installation (Project)

When creating new CLI projects which use the gunner CLI engine, you can install gunner into your project as you would other npm modules

Using npm

```bash
> npm install @codedungeon/gunner
```

Using yarn

```bash
> yarn add @codedungeon/gunner
```

## Using Gunner CLI

You can use the Gunner CLI to create new CLI projects

```bash
gunner new <project>
```

You will receive a series of prompts to guide you through the new project creation process

<h4>
    <img src="docs/images/gunner-prompts.png" width="30%" height="30%" alt="Gunner Prompts">
</h4>

After new project has completed, you will see an installation summary similar to the following which will instruct what needs to happen next.

<h4>
    <img src="docs/images/install-summary.png" width="30%" height="30%" alt="Gunner Prompts">
</h4>

Change directory to new project to review your new CLI project scaffoled with the gunner starter.

### Create new CLI command

Using the Gunner CLI, you can create new CLI commands as follows

```bash
gunner new:command test --name test
```

A new CLI command will be created in the `src/commands` directory

```js
module.exports = {
  name: 'test',
  description: 'test description',
  disabled: false,
  hidden: false,
  usage: 'Do something cool, after all this is your command!',
  flags: {
    // example flag, adjust accordingly
    name: { aliases: ['n'], description: 'Command name', required: false },
  },
  execute(toolbox) {
    let name = toolbox.strings.titleCase(toolbox.arguments.name || 'world')
    toolbox.print.info(`Hello ${name}`)
  },
}
```

You can see your new CLI command in action by executing

```bash
hello test --name Mike
```

which will print the info

```bash
Hello Mike
```

Now, have a look at the CLI help

```bash
hello --help
```

```bash
🚧 hello v0.0.1 build 1
   Crafted with love by Mike Erickson ((https://github.com/mikeerickson))

Usage:
  hello info --limit 5

Commands:
  say-hello [args]              Say hello to my little friend!
  test [args]                   test description

Options:
  --help, -h, -H                Shows Help (this screen)
  --overwrite, -o               Overwrite Existing Files(s) if creating in command
  --quiet, -q                   Quiet mode (suppress console output)
  --version, -v, -V             Show Version
                                 (includes table of hello options)

Examples:
  hello info --versions 7,8
```

And, you can see command level help using the following example

```bash
hello test --help
```

Will output command help

```bash
🛠  test
   test description

Usage:
  Do something cool, after all this is your command!

Options:
  --name, -n              Command name
```

## Adding Gunner CLI Engine to existing projects

In addition to creating new CLI projects discussed above, you can also add the Gunner CLI Engine to an existing Node based project by installing `@codedungeon/gunner` (see Installation above)

- Create `index.js` file and add the following (showing the bare minimum required)

```js
#!/usr/bin/env node

const { CLI } = require('@codedungeon/gunner')
const pkgInfo = require('./package.json')

const app = new CLI(process.argv, __dirname)
  .usage(`${pkgInfo.packageName} make:command TestCommand --name test:command`)
  .options(/* if not called, options will be suppressed in help dialog */)
  .version(/* version string override, if not supplied default version info will be displayed */)
  .examples(
    /* if not called, examples will be suppressed in help dialog */
    `${pkgInfo.packageName} make:command TestCommand --name hello`
  )
  .run()
```

- Create new command in the `src/commands` directory (you can use the `gunner new:command` to quickly scaffold a new CLI command)

```bash
gunner make:command test --name test --description="test description"
```

- Test you new CLI by executing `node index.js` from the root of your project

```bash
node index.js --help
```

## Gunner API

Refer to `docs/getting-started.md`

Refer to `docs/api.md`

## License

Copyright &copy; 2019-2021 Mike Erickson
Released under the MIT license

## Credits

Gunner written by Mike Erickson

E-Mail: [mike.erickson@codedungeon.io](mailto:mike.erickson@codedungeon.io)

Twitter: [@codedungeon](http://twitter.com/codedungeon)

Website: [codedungeon.io](http://codedungeon.io/gunner)

---
_Source: https://npm.io/package/@codedungeon/gunner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
