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

comline

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

comline - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

18

dist/cli.js
// src/cli.ts
import * as fs from "node:fs";
import * as path from "node:path";
import {zodToJsonSchema} from "zod-to-json-schema";

@@ -122,3 +123,3 @@

optionsSchema,
discoverConfigPath
discoverConfigPath = () => path.join(process.cwd(), `${cliName}.config.json`)
}, logger = {

@@ -134,5 +135,7 @@ error: (...args) => console.error(...args)

if (configFilePath) {
const configText = fs.readFileSync(configFilePath, `utf-8`);
const optionsFromConfigJson = JSON.parse(configText);
optionsFromConfig = optionsSchema.parse(optionsFromConfigJson);
if (fs.existsSync(configFilePath)) {
const configText = fs.readFileSync(configFilePath, `utf-8`);
const optionsFromConfigJson = JSON.parse(configText);
optionsFromConfig = optionsSchema.parse(optionsFromConfigJson);
}
}

@@ -143,3 +146,4 @@ }

const [key, config] = entry;
const { flag: flag2, parse, required, description, example } = config;
const { flag: flag2, required, description, example } = config;
const parse = `parse` in config ? config.parse : parseStringOption;
const argumentInstances = passed.filter((arg) => arg.startsWith(`--${key}`) || arg.startsWith(`-`) && !arg.startsWith(`--`) && flag2 && arg.split(`=`)[0].includes(flag2));

@@ -172,5 +176,5 @@ switch (argumentInstances.length) {

suppliedOptions,
writeJsonSchema: (path) => {
writeJsonSchema: (path2) => {
const jsonSchema = zodToJsonSchema(optionsSchema);
fs.writeFileSync(path, JSON.stringify(jsonSchema, null, `\t`));
fs.writeFileSync(path2, JSON.stringify(jsonSchema, null, `\t`));
}

@@ -177,0 +181,0 @@ };

{
"name": "comline",
"version": "0.0.0",
"version": "0.0.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "author": {

import * as fs from "node:fs"
import * as path from "node:path"
import type { ZodSchema } from "zod"

@@ -6,4 +7,5 @@ import { zodToJsonSchema } from "zod-to-json-schema"

import type { Flag } from "./flag"
import { OPTIONAL, type Tree, type TreePath } from "./tree"
import type { Tree, TreePath } from "./tree"
import { retrievePositionalArgs } from "./retrieve-positional-args"
import { parseStringOption } from "./option-parsers"

@@ -22,5 +24,10 @@ export * from "./option-parsers"

export type CliOption<T extends CliOptionValue> = {
export type CliOption<T extends CliOptionValue> = (T extends string
? {
parse?: (arg: string) => T
}
: {
parse: (arg: string) => T
}) & {
flag?: Flag
parse: (arg: string) => T
required: T extends undefined ? false : true

@@ -72,3 +79,4 @@ description: string

optionsSchema,
discoverConfigPath,
discoverConfigPath = () =>
path.join(process.cwd(), `${cliName}.config.json`),
}: CommandLineInterface<PositionalArgs, Options>,

@@ -92,5 +100,7 @@ logger = {

if (configFilePath) {
const configText = fs.readFileSync(configFilePath, `utf-8`)
const optionsFromConfigJson = JSON.parse(configText)
optionsFromConfig = optionsSchema.parse(optionsFromConfigJson)
if (fs.existsSync(configFilePath)) {
const configText = fs.readFileSync(configFilePath, `utf-8`)
const optionsFromConfigJson = JSON.parse(configText)
optionsFromConfig = optionsSchema.parse(optionsFromConfigJson)
}
}

@@ -102,3 +112,4 @@ }

const [key, config] = entry
const { flag, parse, required, description, example } = config
const { flag, required, description, example } = config
const parse = `parse` in config ? config.parse : parseStringOption
const argumentInstances = passed.filter(

@@ -105,0 +116,0 @@ (arg) =>

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