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
```bash
php generate.php
php generate.php [global.json Relative Location] [Output Directory Relative Direction]
```
## 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
```bash
php generate.php
php generate.php [global.json Relative Location] [Output Directory Relative Direction]
```
## 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.
*/
$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->generate_static();
if (isset($argv[2])) $Daux->generate_static($argv[2]);
else $Daux->generate_static();
?>

View File

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