# @ynpx/ynpx-argv

> YNPX 命令列參數解析器，用於解析 ynpx 工具的命令列選項和參數 (Command line argument parser for YNPX tool)

Latest version **1.0.19** (published 2026-03-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install @ynpx/ynpx-argv
pnpm add @ynpx/ynpx-argv
yarn add @ynpx/ynpx-argv
bun add @ynpx/ynpx-argv
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.19 |
| Published | 2026-03-09 |
| First published | 2020-07-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 46.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 32 |
| Author | bluelovers |
| Maintainers | bluelovers |
| Keywords | ynpx, ypx, argv, args, parser, yargs, cli, command-line, parse, argument, parameter, npm, yarn, package, typescript |

## Links

- npm: https://www.npmjs.com/package/@ynpx/ynpx-argv
- Repository: https://github.com/bluelovers/ws-ypx
- Homepage: https://github.com/bluelovers/ws-ypx/tree/master/packages/@ynpx/ynpx-argv#readme
- Issues: https://github.com/bluelovers/ws-ypx/issues
- npm.io page: https://npm.io/package/@ynpx/ynpx-argv

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) >=2
- [yargs](https://npm.io/package/yargs.md) <18 >=17.7.2

## 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

- 1.0.19 (latest) — 2026-03-09
- 1.0.18 — 2026-03-09
- 1.0.14 — 2022-10-30
- 1.0.13 — 2022-08-28
- 1.0.12 — 2022-08-16
- 1.0.11 — 2022-07-07
- 1.0.10 — 2022-02-06
- 1.0.9 — 2021-08-26
- 1.0.7 — 2021-06-05
- 1.0.6 — 2021-02-09
- 1.0.5 — 2020-07-30
- 1.0.4 — 2020-07-23
- 1.0.3 — 2020-07-18
- 1.0.2 — 2020-07-18
- 1.0.1 — 2020-07-18

## README

# @ynpx/ynpx-argv

YNPX 命令列參數解析器，用於解析 ynpx 工具的命令列選項和參數。
Command line argument parser for YNPX tool, used to parse command line options and arguments.

## 安裝 (Installation)

```bash
# 使用 yarn / Using yarn
yarn add @ynpx/ynpx-argv

# 使用 yarn-tool / Using yarn-tool
yarn-tool add @ynpx/ynpx-argv

# yt 是 yarn-tool 的別名 / yt is an alias for yarn-tool
yt add @ynpx/ynpx-argv

# 使用 pnpm / Using pnpm
pnpm add @ynpx/ynpx-argv

# 使用 npm / Using npm
npm install @ynpx/ynpx-argv
```

## 功能 (Features)

- 解析 ynpx 命令列參數 / Parse YNPX command line arguments
- 支援 `-p/--package` 多套件指定 / Support `-p/--package` multiple package specification
- 自動處理 `--` 分隔的額外參數 / Auto-handle `--` separated extra arguments
- 提供完整的 TypeScript 型別支援 / Full TypeScript type support

## 使用範例 (Usage Examples)

```typescript
import parseArgv from '@ynpx/ynpx-argv';

// 基本使用 / Basic usage
const argv = parseArgv(['-p', 'lodash', 'mocha', '--', '-R', 'spec']);
console.log(argv.package); // ['lodash']
console.log(argv._);       // ['mocha']
console.log(argv['--']);   // ['-R', 'spec']

// 多套件指定 / Multiple packages
const argv2 = parseArgv(['-p', 'esm', '-p', 'ts-node', 'mocha']);
console.log(argv2.package); // ['esm', 'ts-node']

// 指定套件管理器 / Specify package manager
const argv3 = parseArgv(['--pm', 'pnpm', 'eslint']);
console.log(argv3.npmClient); // ['pnpm']

// 多個套件管理器 / Multiple package managers
const argv4 = parseArgv(['--npmClient', 'yarn', '--pm', 'pnpm', 'node']);
console.log(argv4.npmClient); // ['yarn', 'pnpm']
```

## 介面 (Interfaces)

### IYPXArgumentsCore

核心參數介面，定義支援的所有選項：
Core arguments interface defining all supported options:

| 選項 (Option) | 類型 (Type) | 說明 (Description) |
|--------------|------------|-------------------|
| `package` | `string[]` | 要安裝的套件列表 / List of packages to install |
| `quiet` | `boolean?` | 靜默模式 / Quiet mode |
| `preferOffline` | `boolean?` | 優先使用離線快取 / Prefer offline cache |
| `cwd` | `string?` | 工作目錄 / Working directory |
| `ignoreExisting` | `boolean?` | 忽略已存在檢查 / Skip existence check |
| `noInstall` | `boolean?` | 跳過安裝 / Skip installation |
| `userconfig` | `string?` | Yarn 設定檔路徑 / Yarn config file path |
| `debugBin` | `boolean?` | 除錯二進制模式 / Debug binary mode |
| `debugMode` | `boolean?` | 除錯模式 / Debug mode |
| `npmClient` | `string[]?` | 套件管理器列表（例如：npm、yarn、pnpm）/ Package manager list (e.g., npm, yarn, pnpm) |

## API

### parseArgv(inputArgv: string[]): IYPXArguments

解析命令列參數並返回解析結果。
Parse command line arguments and return the parsed result.

### parseArgvCore(inputArgv: string[]): Argv

建立並配置 yargs 實例，返回未解析的 yargs 物件。
Create and configure yargs instance, return the unparsed yargs object.

## 相關項目 (Related Projects)

- [ynpx](https://github.com/bluelovers/ws-ypx) - 基於 Yarn 的 npx 替代工具 / Yarn-based npx alternative

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