From 386b6986c03dbd41741625063ded02599a1f2038 Mon Sep 17 00:00:00 2001 From: Barry <5648875+BarryMode@users.noreply.github.com> Date: Wed, 29 Nov 2017 11:09:58 -0600 Subject: [PATCH] v0.9.2: Set simultaneous file limit --- CHANGELOG.md | 6 ++++++ README.md | 9 ++++++++- blueprints.yaml | 2 +- cli/GenerateCommand.php | 31 ++++++++++++++++++++----------- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 605a2e1..212b762 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v0.9.2 +## 11/29/2017 + +1. [](#new) + * Set how many files will be generated simultaneously. + # v0.9.1 ## 10/23/2017 diff --git a/README.md b/README.md index f72e7c5..a574be4 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ bin/plugin blackhole generate http://localhost/grav ``` - **Output Path** `--output-path` or `-p` - Set the directory to which your static site will be written (relative to Grav root). + Set the directory to which your static site will be written relative to Grav root (default: Grav root). ```bash --output-path ../build @@ -56,6 +56,13 @@ bin/plugin blackhole generate http://localhost/grav --routes home,about,about/contact ``` +- **Simultaneous Limit** `--simultaneous` or `-s` + Set how many files to generate at the same time (default: 10) + + ```bash + --simultaneous 10 + ``` + - **Force** `--force` or `-f` Overwrite previously generated files. diff --git a/blueprints.yaml b/blueprints.yaml index e2ab63c..8686bc5 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Blackhole -version: 0.9.1 +version: 0.9.2 description: Static site generator for Grav icon: circle author: diff --git a/cli/GenerateCommand.php b/cli/GenerateCommand.php index 85a226d..2282d34 100644 --- a/cli/GenerateCommand.php +++ b/cli/GenerateCommand.php @@ -41,6 +41,12 @@ protected function configure() { InputOption::VALUE_REQUIRED, 'Define a list of routes to only generate certain pages. Accepts a comma-separated list.' ) + ->addOption( + 'simultaneous', + 's', + InputOption::VALUE_REQUIRED, + 'Set how many files to generate at the same time.' + ) ->addOption( 'force', 'f', @@ -53,17 +59,19 @@ protected function serve() { // get options $this->options = [ - 'input-url' => $this->input->getArgument('input-url'), - 'output-url' => $this->input->getOption('output-url'), - 'output-path' => $this->input->getOption('output-path'), - 'routes' => $this->input->getOption('routes'), - 'force' => $this->input->getOption('force') + 'input-url' => $this->input->getArgument('input-url'), + 'output-url' => $this->input->getOption('output-url'), + 'output-path' => $this->input->getOption('output-path'), + 'routes' => $this->input->getOption('routes'), + 'simultaneous' => $this->input->getOption('simultaneous'), + 'force' => $this->input->getOption('force') ]; - $input_url = $this->options['input-url']; - $output_url = $this->options['output-url']; - $output_path = $this->options['output-path']; - $routes = $this->options['routes']; - $force = $this->options['force']; + $input_url = $this->options['input-url']; + $output_url = $this->options['output-url']; + $output_path = $this->options['output-path']; + $routes = $this->options['routes']; + $simultaneous = !empty($this->options['simultaneous']) ? $this->options['simultaneous'] : 10; + $force = $this->options['force']; // curl function pull($light) { @@ -113,6 +121,7 @@ function generate($bh_route, $bh_file_path, $grav_page_data) { $request->bh_file_path = preg_replace('/\/\/+/', '/', $request->bh_route . '/index.html'); $request->input_url = $input_url; $request->output_url = $output_url; + $request->simultaneous = $simultaneous; $request->force = $force; $rollingCurl->add($request); } @@ -147,7 +156,7 @@ function generate($bh_route, $bh_file_path, $grav_page_data) { $rollingCurl->clearCompleted(); $rollingCurl->prunePendingRequestQueue(); }) - ->setSimultaneousLimit(20) + ->setSimultaneousLimit($request->simultaneous) ->execute() ; $this->output->writeln("Done in " . (microtime(true) - $start) . ' seconds');