Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Command/StartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ protected function configure()
->addOption("training", null, InputOption::VALUE_NONE, "Training mode: the solution is displayed after each question")
->addOption('show-multiple-choice', null, InputOption::VALUE_OPTIONAL, 'Should we tell you when the question is multiple choice?', true)
->addArgument('categories', InputArgument::IS_ARRAY, 'Which categories do you want (separate multiple with a space)', array())
->addOption('config', 'c', InputOption::VALUE_OPTIONAL, 'Use custom config', null)
;
}

Expand All @@ -56,15 +57,16 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$config = $this->path($input->getOption('config'));
if ($input->getOption('list')) {
$output->writeln(Loader::getCategories($this->path()));
$output->writeln(Loader::getCategories($config));
return ;
}

$categories = $input->getArgument('categories');
$number = $input->getOption('number');

$set = Loader::init($number, $categories, $this->path());
$set = Loader::init($number, $categories, $config);

if ($set->getQuestions()) {
$output->writeln(
Expand Down Expand Up @@ -166,11 +168,13 @@ protected function displayResults(Set $set, OutputInterface $output)
/**
* Returns configuration file path
*
* @return String $path The configuration filepath
* @param null|string $config
*
* @return String $path The configuration filepath
*/
protected function path()
protected function path($config = null)
{
return dirname(__DIR__).DIRECTORY_SEPARATOR.'config.yml';
return $config ? $config : dirname(__DIR__).DIRECTORY_SEPARATOR.('config.yml');
}
}

19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ This is the CLI tool to train on certifications.
## Using Composer
```
$ composer create-project certificationy/certificationy-cli
$ php certificationy.php
$ bin/certificationy
```

## More run options

### Select the number of questions
```
$ php certificationy.php start --number=10
$ bin/certificationy start --number=10
```

The default value is 20.

### List categories
```
$ php certificationy.php start --list [-l]
$ bin/certificationy start --list [-l]
```

Will list all the categories available

### Only questions from certain categories
```
$ php certificationy.php start "Automated tests" "Bundles"
$ bin/certificationy start "Automated tests" "Bundles"
```

Will only get the questions from the categories "Automated tests" and "Bundles"
Expand All @@ -45,14 +45,21 @@ Use the category list from [List categories](#list-categories)

### Show if a question has multiple choices
```
$ php certificationy.php start --show-multiple-choice
$ bin/certificationy start --show-multiple-choice
```

![Multiple choices](https://cloud.githubusercontent.com/assets/795661/3308225/721b5324-f679-11e3-8d9d-62ba32cd8e32.png "Multiple choices")

### Set custom configuration file
```
$ bin/certificationy start --config=../config.yml
```

Will set custom config file

### And all combined
```
$ php certificationy.php start --number=5 --show-multiple-choice "Automated tests" "Bundles"
$ bin/certificationy start --number=5 --show-multiple-choice "Automated tests" "Bundles"
```

* 5 questions
Expand Down
11 changes: 9 additions & 2 deletions certificationy.php → bin/certificationy
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
* file that was distributed with this source code.
*/

require __DIR__ . '/vendor/autoload.php';
$autoloadFiles = array(__DIR__.'/../vendor/autoload.php',
__DIR__.'/../../../autoload.php');

foreach ($autoloadFiles as $autoloadFile) {
if (file_exists($autoloadFile)) {
require_once $autoloadFile;
}
}

use Certificationy\Cli\Command\StartCommand;
use KevinGH\Amend\Command;
Expand All @@ -24,7 +31,7 @@

$application = new Application(APPLICATION_NAME, VERSION);

$config = Yaml::parse(file_get_contents('config.yml'));
$config = Yaml::parse(file_get_contents(__DIR__.'/../config.yml'));
$updateCommand = new Command('self-update');
$updateCommand->setManifestUri($config['manifest_uri']);
$application->add($updateCommand);
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
},
"bin": [
"bin/certificationy"
]
}