Giter VIP home page Giter VIP logo

catacli's Issues

can't create no flag commands.

I tried create simple command that uses only arguments (like a file path).
But if do not assignment flag property for makeCommand function 2nd arguments, get an Error: TypeError: t2 is not a function

I did investigation for this.

makeCommand option of flag is Partial type intype CommandSpec.

catacli/src/command.ts

Lines 5 to 26 in 14d54bd

export type CommandSpec<
N extends string,
F extends (args: string[]) => any,
P extends (args: string[]) => any
> = {
name: N;
description?: string;
version?: string;
usage?: string;
flag?: F;
positionalArguments?: P;
handler?: F extends (args: string[]) => infer V
? P extends (args: string[]) => infer U
? (
args: U,
flags: V,
helpFn?: Function,
metaInfo?: { spec?: CommandSpec<N, F, P>; rawArgs?: string[] }
) => any
: never
: never;
};

But inside of makeCommand function, spec.flag is calling as a function.

catacli/src/command.ts

Lines 45 to 54 in 14d54bd

export function makeCommand<
N extends string,
T extends (args: string[]) => any,
P extends (args: string[]) => any
>(spec: CommandSpec<N, T, P>, showHelp = defaultHelp): Command {
return (args: string[], parentSpec) => {
const parser = showHelp
? reduceFlag(defaultHelpFlag, spec.flag)
: spec.flag;
const flags = parser(args);

In short, if do not assignment flag property, spec.flag is undefined but called as as function.
then get an Error: TypeError: t2 is not a function.

that is correct?
and if correct this, may i try create a pull request?

Subcommand does not work.

I tried to create subcommand, using same code as README subcommand example.
There is build error.

ERROR in /path/to/repo/src/index.ts
./src/index.ts
[tsl] ERROR in /path/to/repo/src/index.ts(73,3)
      TS2322: Type '(args: any, _: any, helpFn: any, { spec, rawArgs }: { spec: any; rawArgs: any; }) => void' is not assignable to type '(args: { COMMAND_NAME: { value: string; position: number[]; usage: string; }; }, flags: ParseResult<boolean, "opts1"> & ParseResult<number, "opts2"> & ParseResult<string, "opts3">, helpFn?: Function | undefined, metaInfo?: { ...; } | undefined) => any'.
  Types of parameters '__3' and 'metaInfo' are incompatible.
    Type '{ spec?: CommandSpec<"example", (args: string[]) => ParseResult<boolean, "opts1"> & ParseResult<number, "opts2"> & ParseResult<string, "opts3">, (args: string[]) => { ...; }> | undefined; rawArgs?: string[] | undefined; } | undefined' is not assignable to type '{ spec: any; rawArgs: any; }'.
      Type 'undefined' is not assignable to type '{ spec: any; rawArgs: any; }'.

Is there any problem on subcommand example?

$node -v
v14.9.0
$grep catacli package.json 
    "catacli": "^0.1.3",

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency @types/node to v20.14.6
  • Update actions/checkout action to v4
  • Update actions/setup-node action to v4
  • Update dependency eslint-config-prettier to v9
  • Lock file maintenance
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/pr.yml
  • actions/checkout v1
  • actions/setup-node v1
npm
package.json
  • source-map-support ^0.5.12
  • @types/jest 27.5.2
  • @types/node 20.12.11
  • @typescript-eslint/eslint-plugin 1.13.0
  • @typescript-eslint/parser 1.13.0
  • eslint 7.32.0
  • eslint-config-prettier 8.10.0
  • eslint-plugin-prettier 4.0.0
  • jest 27.5.1
  • prettier 1.19.1
  • rimraf 3.0.2
  • ts-jest 27.1.4
  • ts-node 9.1.1
  • typescript 4.9.5

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.