From 57ffe74776d05f391c63dd3551dded1b138b1a03 Mon Sep 17 00:00:00 2001 From: Gautham Warrier Date: Tue, 12 Aug 2014 02:06:04 +0530 Subject: [PATCH] Add support for passing custom Config file & Output Directory via CLI --- README.md | 2 +- docs/00_Getting_Started.md | 2 +- generate.php | 7 ++++--- libs/daux.php | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b68f9f2..7f0df5f 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/00_Getting_Started.md b/docs/00_Getting_Started.md index 5e7f87e..72abce3 100644 --- a/docs/00_Getting_Started.md +++ b/docs/00_Getting_Started.md @@ -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 diff --git a/generate.php b/generate.php index e2a0ca3..6791a91 100644 --- a/generate.php +++ b/generate.php @@ -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(); ?> \ No newline at end of file diff --git a/libs/daux.php b/libs/daux.php index 6609e20..8d3cc48 100644 --- a/libs/daux.php +++ b/libs/daux.php @@ -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);