Code Monkey home page Code Monkey logo

cling's People

Contributors

github-actions[bot] avatar simonlovesyou avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

cling's Issues

parser: Propagate unknown arguments

Propagate unknown arguments from the parser at the root level but also on each command

Schema

const schema = parser({
  commands: {
    foo: {}
  }
} as const, {})

Argvs

Unknown command

argv: baz

should output

{
  commands: {
    _unknown: [{
      name: 'baz'
    }]
  }
}

Unknown command & positional

argv: baz quux

should output

{
  commands: {
    _unknown: [{ name: 'baz', _unknown: [{ value: 'quux' }] }]
  }
}

Unknown command & argument

argv: baz --quux=foo

should output

{
  commands: {
    _unknown: [{
     name: 'baz',
     _unknown: [{
       name: 'quux',
       value: 'foo'
    }]
  }]
}

Unknown argument

argv: foo --quux=foo

should output

{
  commands: {
    foo: {
      _unknown: [{
        name: 'quux',
        value: 'foo'
    }
}

Display enum values in help output

cling({
  arguments: {
    role: {
      type: 'string',
      enum: ['user', 'admin'],
      description: "The users' role"
    }
  }
} as const)

should output the following help output:

Usage:
  cli --role (user|admin)

Options:
  -h --help     Show this screen.

Arguments:
  --role  The users' role in the organization. (user|admin)

Add key duplication safety

Add runtime & static logic for determining whether or not a argument / option has a conflicting name.

Static logic does not seem to be possible yet, see this PR

Usage list is joined with a comma between arguments

cling({
  arguments: {
    email: {
      type: 'array',
      items: [{
        type: 'string'
      }, {
        type: 'number'
      }],
      // description: "The users' email",
    },
    age: {
      type: 'integer'
    },
  }
} as const)

will output Usage: test [--email],[--age], should be Usage: test [--email] [--age]

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.