Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clia

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clia - npm Package Compare versions

Comparing version 2020.8.11 to 2024.5.29

17

package.json
{
"name": "clia",
"version": "2020.8.11",
"description": "Command line parser and t3st example project",
"version": "2024.5.29",
"description": "Command line arguments parser",
"main": "index.js",

@@ -9,3 +9,3 @@ "scripts": {

"start": "npx nodemon -x \"npx t3st\"",
"lint": "npx eslint ."
"lint": "npx eslint@9 ."
},

@@ -17,6 +17,7 @@ "files": [

"type": "git",
"url": "git+https://github.com/devmachiine/clia.git"
"url": "git+https://github.com/datafilter/clia.git"
},
"keywords": [
"cli",
"arguments",
"parser",

@@ -27,11 +28,11 @@ "t3st",

],
"author": "devmachiine",
"author": "datafilter",
"license": "MIT",
"bugs": {
"url": "https://github.com/devmachiine/clia/issues"
"url": "https://github.com/datafilter/clia/issues"
},
"homepage": "https://github.com/devmachiine/clia#readme",
"homepage": "https://github.com/datafilter/clia#readme",
"devDependencies": {
"t3st": "^2020.8.6"
"t3st": "^2020.10.14"
}
}
# clia
Command line arguments parser and [t3st](https://www.npmjs.com/package/t3st) example project.
Command line arguments parser. Similar to [command-line-args](https://www.npmjs.com/package/command-line-args), [getopts](https://www.npmjs.com/package/getopts) and [nopt](https://www.npmjs.com/package/nopt), but quite smaller with less files and jokes.
You can give it a quick test [in your browser on runkit](https://npm.runkit.com/clia) with
```js
const conf = clia('hello -a -ab -d world'.split(' '))
```
Like the other parsers, clia follows the same syntax conventions documented in [design docs](https://github.com/datafilter/clia/blob/master/notes.md) with [lots of tests/examples here](
https://github.com/datafilter/clia/tree/master/tests).
## usage

@@ -10,6 +19,6 @@

```bash
node your-node-app hello -a -ab -d world
node your-app hello -a -ab -d world
```
In your-node-app:
In `your-app` you get parsed command line arguments as follows:

@@ -21,5 +30,2 @@ ```js

// test in your browser on: https://npm.runkit.com/clia
// const conf = clia('hello -a -ab -d world'.split(' '))
conf === {

@@ -38,2 +44,32 @@ // arguments before any options

## alias
Pass a second argument to clia to specify aliases:
```javascript
clia('run -o yaml --d=/usr/bin --fruit=mango'.split(' ')
, ['output', 'directory', 'fruit'])
```
yields
```javascript
{
arg: {
o: 'yaml', output: 'yaml',
d: '/usr/bin', directory: '/usr/bin',
fruit: 'mango'
},
args: {
o: ['yaml'], output: ['yaml'],
d: ['/usr/bin'], directory: ['/usr/bin'],
// note key-value doesn't set option
// even when kv/value matches alias
fruit: ['mango']
},
// note key-value doesn't set opt
// even when kv/value is short option that has an alias
opt: { o: true, output: true },
plain: ['run']
}
```
## edge cases

@@ -84,4 +120,3 @@

Key-values with missing key or value are saved as-is:
eg:
Key-values with missing key or value are saved as is, eg:

@@ -92,47 +127,7 @@ option `--store=` yields: `{ .. opt: { 'store=': true }`

## example
## alias
An example of where clia is used to parse command line arguments, with "autocomplete" _(`Cli option not found. Did you mean ___`)_ can be found [here](https://github.com/datafilter/t3st/blob/master/bin/parse.js)
```javascript
clia('run -o yaml --d=/usr/bin --fruit=mango'.split(' ')
, ['output', 'directory', 'fruit'])
```
yields
```javascript
{
arg: {
o: 'yaml', output: 'yaml',
d: '/usr/bin', directory: '/usr/bin',
fruit: 'mango'
},
args: {
o: ['yaml'], output: ['yaml'],
d: ['/usr/bin'], directory: ['/usr/bin'],
// note key-value doesn't set option
// even when kv/value matches alias
fruit: ['mango']
},
// note key-value doesn't set opt
// even when kv/value is short option that has an alias
opt: { o: true, output: true },
plain: ['run']
}
```
## Docs
[All examples here](https://github.com/devmachiine/clia/tree/master/tests)
[Dev/specs](https://github.com/devmachiine/clia/blob/master/notes.md)
![CI](https://github.com/devmachiine/clia/workflows/CI/badge.svg)
[![License](https://img.shields.io/badge/license-MIT-black)](https://img.shields.io/badge/license-MIT-black)
<!-- Todo Metrics
[![Snyk](https://img.shields.io/npm/t3st/two.svg)](https://npmjs.com/two)
[![Coverage](https://img.shields.io/npm/t3st/four.svg)](https://npmjs.com/four)
[![OtherMetric](https://img.shields.io/npm/t3st/one.svg)](https://npmjs.com/one)
[![OtherMetric](https://img.shields.io/npm/t3st/three.svg)](https://npmjs.com/three)
-->

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc