New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cilly

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cilly - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

10

dist/cli-command.js

@@ -67,8 +67,2 @@ "use strict";

const short = this.getShortName(option);
if (name in this.opts) {
throw new exceptions_1.DuplicateOptionException(name, this.dump());
}
if (short in this.shortNameMap) {
throw new exceptions_1.DuplicateOptionException(short, this.dump());
}
if (option.negatable) {

@@ -87,3 +81,3 @@ const negatedFlag = token_parser_1.getNegatedFlag(option.name[1]);

if (command.inheritOpts) {
command.opts = Object.assign(Object.assign({}, this.opts), command.opts);
command.withOptions(...Object.values(this.opts));
}

@@ -162,4 +156,2 @@ this.subCommands[command.name] = command;

const parsed = this.consumeArgument(this.args.shift(), q);
if (!parsed)
continue;
const [name, value] = parsed;

@@ -166,0 +158,0 @@ this.parsed.args[name] = value;

2

package.json
{
"name": "cilly",
"version": "1.0.9",
"version": "1.0.10",
"description": "The last library you'll ever need for building intuitive, robust and flexible CLI tools with Node.js and TypeScript.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -11,2 +11,3 @@ # Cilly

- [Installation](#installation)
- [Motivation](#motivation)
- [Basic usage](#basic-usage)

@@ -30,3 +31,5 @@ - [Documentation](#documentation)

- [Custom help handlers](#custom-help-handlers)
- [Custom version handlers](#custom-version-handlers)
- [Exception handling](#exception-handling)
- [Contributing](#contributing)

@@ -38,2 +41,16 @@ # Installation

# Motivation and features
The `cilly` package takes a lot of inspiration from great packages such as [commander.js](https://github.com/tj/commander.js).
Cilly presents a small set of strong concepts that simplify the processing flow from input to invoking a command handler.
The primary features that separate `cilly` from other libraries are:
1. Separate `parse()` and `process()` methods
2. Option sharing and inheritance between commands and subcommands
3. `onParse()`, `onProcess()` and `validator()` hooks for options and arguments
4. Custom usage documentation
5. Support for generating documentation from command definitions
6. Fully typed
7. Fully tested ![coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Minibrams/1708995a4933a08f4838df0243926653/raw/cilly__main.json)
# Basic usage

@@ -599,2 +616,13 @@ With a file called `build.ts`:

## Custom version handlers
You can set the version of a command with `.withVersion('1.2.3')`. This will set the version and add a `--version` option that prints the version.
If you want to override how the version is displayed, you can do so by passing a handler:
```typescript
new CliCommand('build')
.withVersion('1.2.3', (command: CommandDefinition) => {
console.log(`The version of this command is ${command.version}`)
process.exit()
})
```
## Exception handling

@@ -619,1 +647,21 @@ All exceptions thrown by `cilly` extend the `CillyException` class. If you want to catch each exception and handle them individually, here's the full list of exceptions thrown by `cilly`:

```
# Contributing
Contributions are greatly appreciated and lovingly welcomed!
In your pull request, make sure to link the issue you're addressing. If no issue exists, make one first so we have a chance to discuss it first.
Always write tests for the functionality you add or change. See the `cli-command.test.ts` and `token-parser.test.ts` files for examples.
As always, use the linter provided in the project (`.eslintrc.json`) and stick to the coding style of the project.
## Setup
1. Install everything with `npm i`
2. Run tests with `npm test`
## Debugging
When debugging, take not that both `parse()` and `process()` strip the two first arguments off of `process.argv` when invoked.
When you want to see how an input would be parsed, set the `raw` option in `parse()` and `process()`:
```typescript
const { args, opts, extra } = new CliCommand('build').parse(['build', '--unknown-option'], { raw: true })
```
When `raw` is `true`, the input array is not changed.
The `.vscode/launch.json` file contains a configuration for debugging the test files `Mocha Tests`, allowing you to put breakpoints and step through your tests.
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