rocketeers / docs

Rocketeer's documentation
7 stars 25 forks source link

Getting options for a custom taks #31

Open Anahkiasen opened 8 years ago

Anahkiasen commented 8 years ago

@acmitch commented on Thu Aug 06 2015

So I've created a custom task, however, when trying to call $this->getOption('start_date'); I get the error

  [RuntimeException]
  The "--start_date" option does not exist

deploy:custom [-P|--parallel] [-p|--pretend] [-C|--on="..."] [-S|--stage="..."] [-B|--branch="..."] [--host="..."] [--username="..."] [--password="..."] [--key="..."] [--keyphrase="..."] [--agent="..."] [--repository="..."]

Looking at the migration tasks and others. It seems custom options can be passed through?


@acmitch commented on Tue Aug 11 2015

Wanted to follow up for anyone having similar issues. This is very possible.

All you have to do is create a custom command which extends BaseTaskCommand and override the getOptions child function.

To get your newly created command class to autoload, simply place your code in one of the autoloaded folders such as 'strategies' or 'tasks'.

I know this comment is very broad, so check out how Anahkiasen handles extending the 'deploy' command here.

You can see he has a class doing what I just described above. @Anahkiasen you really need some documenation on this. I love this library but to use it as a task runner the ability to have rocketeer as an extension of my libraries is really helpful.

For the short term just simply autoloading a 'commands' directory if it exists would be great!


@Anahkiasen commented on Tue Aug 11 2015

As you may have noticed I'm rather buys currently so Rocketeer is a bit in pause, but all PRs are welcome to the rocketeer/docs repo