# commander-github-actions

> Build GitHub Action inputs using commander

Latest version **0.2.1** (published 2022-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install commander-github-actions
pnpm add commander-github-actions
yarn add commander-github-actions
bun add commander-github-actions
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2022-09-01 |
| First published | 2022-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 13.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Marcelo Shima |
| Maintainers | mshima |
| Keywords | commander, github-actions |

## Links

- npm: https://www.npmjs.com/package/commander-github-actions
- Repository: https://github.com/mshima/commander-github-actions
- Issues: https://github.com/mshima/commander-github-actions/issues
- npm.io page: https://npm.io/package/commander-github-actions

## Dependencies (1)

- [commander](https://npm.io/package/commander.md) 9.4.0

## Recent versions

- 0.2.1 (latest) — 2022-09-01
- 0.2.0 — 2022-09-01
- 0.1.0 — 2022-08-30

## README

# commander-github-actions

[![License][]](LICENSE)
[![Build Status]](https://github.com/mshima/commander-github-actions/actions/workflows/ci.yml)
[![NPM Package]](https://npmjs.org/package/commander-github-actions)
[![Code Coverage]](https://codecov.io/gh/mshima/commander-github-actions)
[![semantic-release]](https://github.com/semantic-release/semantic-release)

[license]: https://img.shields.io/badge/UNLICENSED-blue.svg
[build status]: https://github.com/mshima/commander-github-actions/actions/workflows/ci.yml/badge.svg
[npm package]: https://img.shields.io/npm/v/commander-github-actions.svg
[code coverage]: https://codecov.io/gh/mshima/commander-github-actions/branch/master/graph/badge.svg
[semantic-release]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg

> Parse and generate GitHub Actions with commander

## Install

```shell
npm install commander-github-actions
```

`commander-github-actions/dev` is used to generate actions.yml. Given the development nature, dependencies are optional:

```shell
npm install yaml lodash --save-dev
```

## Use

program.js:
```js
export function buildCommand(command = new Command()) {
  return command.option(...).addOption(command.createOption(...));
}
```

cli.js (executable):
```js
import { buildCommand } from './program.js';
const options = buildCommand().parse();
```

action.js (GitHub action entrypoint):
```js
import { Command } from 'commander-github-actions';
import { buildCommand } from './program.js';

const options = buildCommand(new Command()).parse();
```

drop in replacements for commander are provided:
```js
import { createCommand, createOption, Command, Option, program } from "commander-github-actions";
```

## Generate action.yml

dev/generate-action-yml.yml
```
#!/usr/bin/env node
import { writeFile } from 'fs/promises';

import { generateActionsYml } from 'commander-github-actions/dev';
import program from '../action/program.js';

await writeFile('action.yml', (await generateActionsYml(program, { runs: { main: 'action/main.js' } })));
```

## Related

https://github.com/tj/commander.js/issues/1787

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