Giter Club home page Giter Club logo

Comments (6)

c4spar avatar c4spar commented on July 22, 2024 1

Hey @umbopepato,

in v0.9.0 is now a new way to resolve your issue. You can use .stopEarly() instead of .useRawArgs(). If stopEarly is enabled, all arguments, starting from the first non option argument, will be interpreted as raw argument.
In contrast to .useRawArgs() the --help and --version option will still work.

from deno-cliffy.

c4spar avatar c4spar commented on July 22, 2024

Hi @umbopepato,

There is an undocumented method useRawArgs() which you can try to use. But it is not fully tested. useRawArgs() disables the parsing and validation of all arguments for the command on which it was called.

Here is an example:

import { Command } from 'https://deno.land/x/[email protected]/command.ts';

await new Command()
  .command('mysubcmd [myarg] [otherArgs...]')
  .useRawArgs()
  .action((options, ...args) => {
    console.log(options, args);
  })
  .parse(Deno.args);
$ deno run raw-args.ts mysubcmd myarg other args and --options
{} [ "myarg", "other", "args", "and", "--options" ]

from deno-cliffy.

c4spar avatar c4spar commented on July 22, 2024

Another way could be to use literal arguments:

mycmd --myoption mysubcmd myarg -- other args and --options
                                ^--

All arguments after -- will be ignored by cliffy. But at the moment the literal argument will not be passed to the action handler or returned by the .parse() method. I have already an issue for that #26. So you have to access Deno.args by your self to get them atm.

from deno-cliffy.

umbopepato avatar umbopepato commented on July 22, 2024

I was literally going to ask you if something like useRawArgs() existed, that's perfect! Also because I'm explicitly trying to avoid the -- separator.

Thanks @c4spar 🙂

from deno-cliffy.

c4spar avatar c4spar commented on July 22, 2024

np 🙂

from deno-cliffy.

umbopepato avatar umbopepato commented on July 22, 2024

Awesome! Thank you @c4spar

from deno-cliffy.

Related Issues (20)

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.