vadimdemedes / ronin

Toolkit for killer CLI applications
http://vdemedes.github.io/ronin
MIT License
299 stars 15 forks source link

run method on Program does not pass global/Program options #27

Closed fnky closed 8 years ago

fnky commented 8 years ago

When setting global options making a new Program and overwriting run() method, neither options are passed to arguments nor is this.global available.

var program = ronin({
  path: path.join(__dirname),
  desc: 'My program',

  options: {
    cat: {
      type: 'string'
    }
  },

  run: function (cat) {
    console.log(cat) // => undefined
    console.log(this.global) // => undefined
  }
})
vadimdemedes commented 8 years ago

You should not overwrite run() method of a program. You should only overwrite run() method of a command.

fnky commented 8 years ago

@vdemedes Then how would I be able to make a program without commands (without hacking around and/or use another library for parsing args) e.g.

$ myProgram someValue anotherValue --option value --flag
vadimdemedes commented 8 years ago

Currently there's no way and I don't plan on doing it at the moment. Ronin is suitable for programs with commands. If you need a program, that does only one task, then you better not use Ronin and go for minimist + minimist-options.