trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.31k forks source link

How does a run plugin specify the format of options? #1474

Open rocky opened 5 years ago

rocky commented 5 years ago

If I am using a run plugin, how do I let truffle know which options take parameters and which don't?

daniyarchambylov commented 5 years ago

I don't see anywhere documented the format of plugin's positional arguments and optional flags (keys). Right now I can run plugin as follows: truffle run my-plugin foo bar baz and config._ contains array ['foo', 'bar', 'baz']. When I run truffle run my-plugin foo bar baz --debug config looks like

{
  _: ['foo', 'bar', 'baz'],
  debug: true,
}

When I run truffle run my-plugin --debug foo bar baz config looks like

{
  _: ['bar', 'baz'],
  debug: 'foo',
}

But what I wanted is to have ['foo', 'bar', 'baz'] as positional arguments and debug being true The same thing happend when I used -d instead of --debug. I got:

{
  _: ['bar', 'baz'],
  d: 'foo',
}

It would be neat to be able to pass flags with and without arguments.

gnidan commented 5 years ago

This is probably somewhat related to #1473, linking so it's easier to find.