Add support for passing custom Config file & Output Directory via CLI

This commit is contained in:
Gautham Warrier 2014-08-12 02:06:04 +05:30
parent 410fea03c1
commit 57ffe74776
4 changed files with 10 additions and 9 deletions

View File

@ -304,7 +304,7 @@ These can be uploaded to a static site hosting service such as pages.github.com
Generating a complete set of pages, with navigation Generating a complete set of pages, with navigation
```bash ```bash
php generate.php php generate.php [global.json Relative Location] [Output Directory Relative Direction]
``` ```
## Running on IIS ## Running on IIS

View File

@ -304,7 +304,7 @@ These can be uploaded to a static site hosting service such as pages.github.com
Generating a complete set of pages, with navigation Generating a complete set of pages, with navigation
```bash ```bash
php generate.php php generate.php [global.json Relative Location] [Output Directory Relative Direction]
``` ```
## Running on IIS ## Running on IIS

View File

@ -64,8 +64,9 @@ negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage. software, even if advised of the possibility of such damage.
*/ */
$Daux = new \Todaymade\Daux\Daux(); if (isset($argv[1])) $Daux = new \Todaymade\Daux\Daux($argv[1]);
else $Daux = new \Todaymade\Daux\Daux($argv[1]);
$Daux->initialize(); $Daux->initialize();
$Daux->generate_static(); if (isset($argv[2])) $Daux->generate_static($argv[2]);
else $Daux->generate_static();
?> ?>

View File

@ -23,7 +23,7 @@
private $params; private $params;
private $mode; private $mode;
function __construct($global_config_file = 'global.json') { function __construct($global_config_file = NULL) {
$this->initial_setup($global_config_file); $this->initial_setup($global_config_file);
} }
@ -34,8 +34,8 @@
if (!$this->error) $this->params = $this->get_page_params(); if (!$this->error) $this->params = $this->get_page_params();
} }
public function generate_static() { public function generate_static($output_dir = NULL) {
$output_dir = $this->local_base . DIRECTORY_SEPARATOR . 'static'; if (is_null($output_dir)) $output_dir = $this->local_base . DIRECTORY_SEPARATOR . 'static';
DauxHelper::clean_copy_assets($output_dir, $this->local_base); DauxHelper::clean_copy_assets($output_dir, $this->local_base);
$this->recursive_generate_static($this->tree, $output_dir, $this->params); $this->recursive_generate_static($this->tree, $output_dir, $this->params);
} }
@ -81,7 +81,7 @@
} }
private function load_global_config($global_config_file) { private function load_global_config($global_config_file) {
$global_config_file = $this->local_base . DIRECTORY_SEPARATOR . $global_config_file; if (is_null($global_config_file)) $global_config_file = $this->local_base . DIRECTORY_SEPARATOR . 'global.json';
if (!file_exists($global_config_file)) { if (!file_exists($global_config_file)) {
$this->generate_error_page('Global Config File Missing', $this->generate_error_page('Global Config File Missing',
'The Global Config file is missing. Requested File : ' . $global_config_file, ErrorPage::FATAL_ERROR_TYPE); 'The Global Config file is missing. Requested File : ' . $global_config_file, ErrorPage::FATAL_ERROR_TYPE);