Skip to content

Commit

Permalink
Merge branch 'main' into pr/zuixinwang/40
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 18, 2024
2 parents 15a0bbc + 2a3b7d3 commit 301e439
Show file tree
Hide file tree
Showing 18 changed files with 2,245 additions and 1,179 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/autofix.yml
@@ -1,9 +1,9 @@
name: autofix.ci # needed to securely identify the workflow
name: autofix.ci # needed to securely identify the workflow

on:
pull_request:
push:
branches: [ "main" ]
branches: ["main"]

permissions:
contents: read
Expand All @@ -14,13 +14,13 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- run: pnpm install
- name: Fix lint issues
run: pnpm run lint:fix
- uses: autofix-ci/action@8caa572fd27b0019a65e4c695447089c8d3138b9
- uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84
with:
commit-message: 'chore: apply automated lint fixes'
commit-message: "chore: apply automated lint fixes"
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -14,12 +14,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- run: pnpm install
- run: pnpm lint
- run: pnpm build
- run: pnpm vitest --coverage
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
41 changes: 41 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,47 @@
# Changelog


## v0.1.6

[compare changes](https://github.com/unjs/citty/compare/v0.1.5...v0.1.6)

### 🩹 Fixes

- **usage:** Render valueHint for positional args ([dbd1d92](https://github.com/unjs/citty/commit/dbd1d92))

### 🏡 Chore

- Apply automated lint fixes ([f00055d](https://github.com/unjs/citty/commit/f00055d))
- Update lockfile ([0e73aad](https://github.com/unjs/citty/commit/0e73aad))

### ❤️ Contributors

- Pooya Parsa ([@pi0](http://github.com/pi0))

## v0.1.5

[compare changes](https://github.com/unjs/citty/compare/v0.1.4...v0.1.5)

### 🚀 Enhancements

- **command:** Return result of run command ([#101](https://github.com/unjs/citty/pull/101))
- **runMain:** Support custom `showUsage` option ([#74](https://github.com/unjs/citty/pull/74))

### 🏡 Chore

- Apply automated lint fixes ([505b621](https://github.com/unjs/citty/commit/505b621))
- Format with prettier ([c4597a1](https://github.com/unjs/citty/commit/c4597a1))

### 🎨 Styles

- Format with prettier ([afea1a5](https://github.com/unjs/citty/commit/afea1a5))

### ❤️ Contributors

- Pooya Parsa ([@pi0](http://github.com/pi0))
- Estéban ([@Barbapapazes](http://github.com/Barbapapazes))
- Katerina Skroumpelou

## v0.1.4

[compare changes](https://github.com/unjs/citty/compare/v0.1.3...v0.1.4)
Expand Down
33 changes: 9 additions & 24 deletions README.md
@@ -1,12 +1,14 @@
# 🌆 citty

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![Codecov][codecov-src]][codecov-href]
[![License][license-src]][license-href]
<!-- automd:badges color=yellow bundlephobia -->

> Elegant CLI Builder
[![npm version](https://img.shields.io/npm/v/citty?color=yellow)](https://npmjs.com/package/citty)
[![npm downloads](https://img.shields.io/npm/dm/citty?color=yellow)](https://npmjs.com/package/citty)
[![bundle size](https://img.shields.io/bundlephobia/minzip/citty?color=yellow)](https://bundlephobia.com/package/citty)

<!-- /automd -->

Elegant CLI Builder

- Fast and lightweight argument parser based on [mri](https://github.com/lukeed/mri)
- Smart value parsing with typecast, boolean shortcuts and unknown flag handling
Expand Down Expand Up @@ -88,7 +90,7 @@ Create a wrapper around command that calls `runMain` when called.

### `runCommand`

Parses input args and runs command and sub-commands (unsupervised).
Parses input args and runs command and sub-commands (unsupervised). You can access `result` key from returnd/awaited value to access command's result.

### `parseArgs`

Expand All @@ -115,20 +117,3 @@ Renders usage and prints to the console
Made with 💛 Published under [MIT License](./LICENSE).

Argument parser is based on [lukeed/mri](https://github.com/lukeed/mri) by Luke Edwards ([@lukeed](https://github.com/lukeed)).

<!-- Badges -->

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/citty?style=flat&colorA=18181B&colorB=F0DB4F
[npm-version-href]: https://npmjs.com/package/citty
[npm-downloads-src]: https://img.shields.io/npm/dm/citty?style=flat&colorA=18181B&colorB=F0DB4F
[npm-downloads-href]: https://npmjs.com/package/citty
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/citty/main?style=flat&colorA=18181B&colorB=F0DB4F
[codecov-href]: https://codecov.io/gh/unjs/citty
[bundle-src]: https://img.shields.io/bundlephobia/minzip/citty?style=flat&colorA=18181B&colorB=F0DB4F
[bundle-href]: https://bundlephobia.com/result?p=citty
[license-src]: https://img.shields.io/github/license/unjs/citty.svg?style=flat&colorA=18181B&colorB=F0DB4F
[license-href]: https://github.com/unjs/citty/blob/main/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsDocs.io-reference-18181B?style=flat&colorA=18181B&colorB=F0DB4F
[jsdocs-href]: https://www.jsdocs.io/package/citty
21 changes: 11 additions & 10 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "citty",
"version": "0.1.4",
"version": "0.1.6",
"description": "Elegant CLI Builder",
"repository": "unjs/citty",
"license": "MIT",
Expand Down Expand Up @@ -33,17 +33,18 @@
"consola": "^3.2.3"
},
"devDependencies": {
"@types/node": "^20.8.3",
"@vitest/coverage-v8": "^0.34.6",
"@types/node": "^20.11.26",
"@vitest/coverage-v8": "^1.3.1",
"automd": "^0.3.6",
"changelogen": "^0.5.5",
"eslint": "^8.51.0",
"eslint": "^8.57.0",
"eslint-config-unjs": "^0.2.1",
"jiti": "^1.20.0",
"prettier": "^3.0.3",
"scule": "^1.0.0",
"typescript": "^5.2.2",
"jiti": "^1.21.0",
"prettier": "^3.2.5",
"scule": "^1.3.0",
"typescript": "^5.4.2",
"unbuild": "^2.0.0",
"vitest": "^0.34.6"
"vitest": "^1.3.1"
},
"packageManager": "pnpm@8.8.0"
"packageManager": "pnpm@8.15.4"
}
1 change: 1 addition & 0 deletions playground/cli.ts
Expand Up @@ -15,6 +15,7 @@ const main = defineCommand({
subCommands: {
build: () => import("./commands/build").then((r) => r.default),
deploy: () => import("./commands/deploy").then((r) => r.default),
debug: () => import("./commands/debug").then((r) => r.default),
},
});

Expand Down
3 changes: 2 additions & 1 deletion playground/commands/build.ts
@@ -1,4 +1,4 @@
import consola from 'consola'
import consola from "consola";
import { defineCommand } from "../../src";

export default defineCommand({
Expand Down Expand Up @@ -35,6 +35,7 @@ export default defineCommand({
type: "positional",
required: false,
description: "path to output directory",
default: ".output",
},
},
run({ args }) {
Expand Down
25 changes: 25 additions & 0 deletions playground/commands/debug.ts
@@ -0,0 +1,25 @@
import consola from "consola";
import { defineCommand } from "../../src";

export default defineCommand({
meta: {
name: "debug",
description: "Debug the project",
hidden: true
},
args: {
verbose: {
type: "boolean",
description: "Output more detailed debugging information",
},
feature: {
type: "string",
default: "database-query",
description: "Only debug a specific function",
},
},
run({ args }) {
consola.log("Debug");
consola.log("Parsed args:", args);
},
});
8 changes: 4 additions & 4 deletions playground/commands/deploy.ts
@@ -1,4 +1,4 @@
import consola from 'consola'
import consola from "consola";
import { defineCommand } from "../../src";

export default defineCommand({
Expand Down Expand Up @@ -47,10 +47,10 @@ export default defineCommand({
type: "boolean",
description: "Dry run the deployment process",
},
outputDir: {
provider: {
type: "positional",
description: "Path to the build output directory",
default: ".output",
description: "Deployment provider",
valueHint: "foo|bar|baz|qux",
},
},
run({ args }) {
Expand Down
26 changes: 24 additions & 2 deletions playground/hello.ts
Expand Up @@ -17,10 +17,32 @@ const command = defineCommand({
type: "boolean",
description: "Use friendly greeting",
},
age: {
type: "number",
description: "Your age",
required: false,
},
adj: {
type: "enum",
description: "Adjective to use in greeting",
options: ["awesome", "cool", "nice"],
default: "awesome",
required: false,
},
},
run({ args }) {
consola.log(`${args.friendly ? "Hi" : "Greetings"} ${args.name}!`);
consola.log(args);
const msg = [
args.friendly ? "Hi" : "Greetings",
args.adj || "",
args.name,
args.age ? `You are ${args.age} years old.` : "",
]
.filter(Boolean)
.join(" ");

consola.log(msg);
},
});

createMain(command)();
createMain(command)({});

0 comments on commit 301e439

Please sign in to comment.