Socket
Socket
Sign inDemoInstall

clipanion

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clipanion - npm Package Compare versions

Comparing version 3.0.0-rc.12 to 3.0.0

2

lib/advanced/builtins/definitions.d.ts

@@ -6,4 +6,4 @@ import { Command } from '../Command';

export declare class DefinitionsCommand extends Command<any> {
static path: string[][];
static paths: string[][];
execute(): Promise<void>;
}

@@ -15,4 +15,4 @@ 'use strict';

}
DefinitionsCommand.path = [[`--clipanion=definitions`]];
DefinitionsCommand.paths = [[`--clipanion=definitions`]];
exports.DefinitionsCommand = DefinitionsCommand;
/// <reference types="node" />
import { Readable, Writable } from 'stream';
import { CommandBuilder } from '../core';
import { ColorFormat } from '../format';
import { CommandClass, Command, Definition } from './Command';
import { CommandOption } from './options/utils';
/**

@@ -126,3 +129,7 @@ * The base context of the CLI.

private readonly builder;
private readonly registrations;
protected readonly registrations: Map<CommandClass<Context>, {
index: number;
builder: CommandBuilder<CliContext<Context>>;
specs: Map<string, CommandOption<unknown>>;
}>;
readonly binaryLabel?: string;

@@ -168,5 +175,25 @@ readonly binaryName: string;

}): string;
private getUsageByRegistration;
private getUsageByIndex;
private format;
protected getUsageByRegistration(klass: CommandClass<Context>, opts?: {
detailed?: boolean;
inlineOptions?: boolean;
}): {
usage: string;
options: {
definition: string;
description: string;
required: boolean;
}[];
};
protected getUsageByIndex(n: number, opts?: {
detailed?: boolean;
inlineOptions?: boolean;
}): {
usage: string;
options: {
definition: string;
description: string;
required: boolean;
}[];
};
protected format(colored?: boolean): ColorFormat;
}

@@ -179,2 +179,27 @@ 'use strict';

usage(command = null, { colored, detailed = false, prefix = `$ ` } = {}) {
var _a;
// In case the default command is the only one, we can just show the command help rather than the general one
if (command === null) {
for (const commandClass of this.registrations.keys()) {
const paths = commandClass.paths;
const isDocumented = typeof commandClass.usage !== `undefined`;
const isExclusivelyDefault = !paths || paths.length === 0 || (paths.length === 1 && paths[0].length === 0);
const isDefault = isExclusivelyDefault || ((_a = paths === null || paths === void 0 ? void 0 : paths.some(path => path.length === 0)) !== null && _a !== void 0 ? _a : false);
if (isDefault) {
if (command) {
command = null;
break;
}
else {
command = commandClass;
}
}
else {
if (isDocumented) {
command = null;
continue;
}
}
}
}
// @ts-ignore

@@ -181,0 +206,0 @@ const commandClass = command !== null && command instanceof Command.Command

@@ -71,2 +71,6 @@ import { LooseTest } from 'typanion';

/**
* Defined to prevent a common typo.
*/
static path: never;
/**
* Paths under which the command should be exposed.

@@ -73,0 +77,0 @@ */

@@ -423,6 +423,6 @@ 'use strict';

isOptionLike: (state, segment) => {
return !state.ignoreOptions && segment.startsWith(`-`);
return !state.ignoreOptions && (segment !== `-` && segment.startsWith(`-`));
},
isNotOptionLike: (state, segment) => {
return state.ignoreOptions || !segment.startsWith(`-`);
return state.ignoreOptions || segment === `-` || !segment.startsWith(`-`);
},

@@ -429,0 +429,0 @@ isOption: (state, segment, name, hidden) => {

@@ -21,2 +21,10 @@ 'use strict';

};
function dedent(text) {
const lines = text.split(`\n`);
const nonEmptyLines = lines.filter(line => line.match(/\S/));
const indent = nonEmptyLines.length > 0 ? nonEmptyLines.reduce((minLength, line) => Math.min(minLength, line.length - line.trimStart().length), Number.MAX_VALUE) : 0;
return lines
.map(line => line.slice(indent).trimRight())
.join(`\n`);
}
function formatMarkdownish(text, { format, paragraphs }) {

@@ -26,7 +34,7 @@ // Enforce \n as newline character

// Remove the indentation, since it got messed up with the JS indentation
text = text.replace(/^[\t ]+|[\t ]+$/gm, ``);
text = dedent(text);
// Remove surrounding newlines, since they got added for JS formatting
text = text.replace(/^\n+|\n+$/g, ``);
// List items always end with at least two newlines (in order to not be collapsed)
text = text.replace(/^-([^\n]*?)\n+/gm, `-$1\n\n`);
text = text.replace(/^(\s*)-([^\n]*?)\n+/gm, `$1-$2\n\n`);
// Single newlines are removed; larger than that are collapsed into one

@@ -37,9 +45,10 @@ text = text.replace(/\n(\n)?\n*/g, `$1`);

// Does the paragraph starts with a list?
const bulletMatch = paragraph.match(/^[*-][\t ]+(.*)/);
const bulletMatch = paragraph.match(/^\s*[*-][\t ]+(.*)/);
if (!bulletMatch)
// No, cut the paragraphs into segments of 80 characters
return paragraph.match(/(.{1,80})(?: |$)/g).join(`\n`);
// Yes, cut the paragraphs into segments of 78 characters (to account for the prefix)
return bulletMatch[1].match(/(.{1,78})(?: |$)/g).map((line, index) => {
return (index === 0 ? `- ` : ` `) + line;
const indent = paragraph.length - paragraph.trimStart().length;
// Yes, cut the paragraphs into segments of (78 - indent) characters (to account for the prefix)
return bulletMatch[1].match(new RegExp(`(.{1,${78 - indent}})(?: |$)`, `g`)).map((line, index) => {
return ` `.repeat(indent) + (index === 0 ? `- ` : ` `) + line;
}).join(`\n`);

@@ -46,0 +55,0 @@ }).join(`\n\n`);

{
"name": "clipanion",
"version": "3.0.0-rc.12",
"version": "3.0.0",
"main": "lib/advanced/index",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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