# @ziggyqubert/do

> A command runner

Latest version **1.1.30** (published 2021-12-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ziggyqubert/do
pnpm add @ziggyqubert/do
yarn add @ziggyqubert/do
bun add @ziggyqubert/do
```

Provides the command `zqDo`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.30 |
| Published | 2021-12-15 |
| First published | 2020-09-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 16 |
| Unpacked size | 56.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ZiggyQubert@gmail.com |
| Maintainers | ziggyqubert |

## Links

- npm: https://www.npmjs.com/package/@ziggyqubert/do
- Repository: https://gitlab.com/ZiggyQubert/do
- Issues: https://gitlab.com/ZiggyQubert/do/issues
- npm.io page: https://npm.io/package/@ziggyqubert/do

## Dependencies (16)

- [glob](https://npm.io/package/glob.md) ^7.1.6
- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [witch](https://npm.io/package/witch.md) ^1.0.3
- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [pkg-dir](https://npm.io/package/pkg-dir.md) ^5.0.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.1
- [inquirer](https://npm.io/package/inquirer.md) ^7.3.3
- [commander](https://npm.io/package/commander.md) ^7.1.0
- [cli-cursor](https://npm.io/package/cli-cursor.md) ^3.1.0
- [strip-ansi](https://npm.io/package/strip-ansi.md) ^6.0.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.12.13
- [global-paths](https://npm.io/package/global-paths.md) ^1.0.0
- [is-interactive](https://npm.io/package/is-interactive.md) ^1.0.0
- [@babel/register](https://npm.io/package/@babel/register.md) ^7.12.13
- [babel-preset-airbnb](https://npm.io/package/babel-preset-airbnb.md) ^5.0.0
- [@babel/plugin-proposal-class-properties](https://npm.io/package/@babel/plugin-proposal-class-properties.md) ^7.13.0

## Recent versions

- 1.1.30 (latest) — 2021-12-15
- 1.1.29 — 2021-12-15
- 1.1.28 — 2021-12-15
- 1.1.27 — 2021-09-13
- 1.1.26 — 2021-09-13
- 1.1.25 — 2021-09-03
- 1.1.24 — 2021-04-30
- 1.1.23 — 2021-04-29
- 1.1.22 — 2021-04-21
- 1.1.21 — 2021-04-09
- 1.1.20 — 2021-04-06
- 1.1.19 — 2021-04-05
- 1.1.18 — 2021-03-25
- 1.1.17 — 2021-03-18
- 1.1.16 — 2021-03-18
- … 22 more at https://npm.io/package/@ziggyqubert/do/versions

## README

# @ziggyqubert/do

This provides an extensible cli tool / manager, its based on [commander](https://www.npmjs.com/package/commander)
with some updates

## usage

From within a project call the cli command `node_modules/.bin/zqDo` this will run the cli in interactive mode,
prompting for the commands and options that should be run, it can also be run completly with command line arguments

## Commands

The few commands provided as part of the cli tool, additional commands can be added as part of the module this is run
under, or its dependencies

### Base commands

- **help <command>** - this provides help for the full cli tool or for the specified command
- **--env <envFile>** - loads a custom .env file into the environment, see dotenv for details
- **--version** - displays the version information for the cli tool
- **run** - this will run a package.json script in the root package or any workspaces defined

### Base options

Options that should apply to all commands or modify the behavior of the cli globally

- **--env <envFile>** - loads a custom .env file into the environment, see dotenv for details
- **--interactive** - forces interactive mode even if some commands are passed in to the cli
- **--verbose** - turns on verbose logging for the cli. see creating plugins below for details of using this

### Plugins

Plugins will automatically loaded from packages within the current working directory, packages above the current working
directory, and any direct dependencies (starting with @namespace/) for those packages

Note: only reading 

## Creating plugins

You can add your own commands to the cli, create a js file in the `zqDo` folder in your package and it will be loaded
automatically as long as it is found as specified above

This file should export a single item either a creation function, or an instance of a commander `Command`.

### Creation function

This will be called, with the commander program, logger, and options as the three arguments, and it can be built off using the
commander chaining syntax

You can call `.childOf('parentName')` to create the command under another command, this allows for extending commands
created in other modules

### Command instance

If returning a command instance it will be added to the structure, the following updates / changes apply -

- if you specify a `parent` property as a string, it will be added to the base command with that name after other commands
  have ben loaded
- the logger is added to the command object as `this.logger` so that it can be used within commands

### Notes

The cli explicitly exits after calling the specified command, so make sure that async functions use await, or return
promises so they dont get terminated before completion

## Logging

A logging instance is provided that auto colors output and handles verbose logging, that should be used for outputting
messaging, logging.verbose respects the `--verbose` flag. See creating plugins above for details

## Commander changes

This changes the behavior of commander in a couple of ways -

- **help output** - this colorizes, re-formats, and provides more detailed help than commander
- **default args** - you can pass `argname: 'defaultValue'` as part of the options parameter to `.command` and that will
  be used as the default value for missing required arguments (and surfaced in the interactive mode) this can also be
  done by setting the `initOptions` property of a `Command` object
- **.childOf()** - Command method to move the command to be a child command of the specified name
- **emitters** - emitted events will now be thrown on all parent commands as well
- **parse:<cmdName>** - an event will be thrown on parse (before the command runs) with the command name, receives the
  command as the first paramater, this can be used for init stuff, see the aws plugin for an example

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