From 17d573e9ee187d9a841b6e481c4bef922e5719ea Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 5 Dec 2016 15:57:08 +0100 Subject: [PATCH] Rename commands [enable=install, disable=remove] + Augment preview + shortcut `xdrm-framework` shell redirecting script --- README.md | 4 ++-- exporter/Exporter.php | 21 ++++++++++++--------- exporter/main.php | 4 ++-- exporter/modules.json | 6 ++++-- xdrm-framework | 2 ++ 5 files changed, 22 insertions(+), 15 deletions(-) create mode 100755 xdrm-framework diff --git a/README.md b/README.md index a4c0412..983f977 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ xdrm-framework is a tool that wraps my framework and all it's component's versio To use the xdrm-framework's project builder, just open a linux terminal and type : 1. `xdrm-framework modules` - to display the available modules -2. `xdrm-framework enable {moduleName} 1.2` - to enable a module and its version (1.2 here) -3. `xdrm-framework disable {moduleName}` - to disable a module +2. `xdrm-framework install {moduleName} 1.2` - to enable a module and its version (1.2 here) +3. `xdrm-framework remove {moduleName}` - to disable a module 4. `xdrm-framework build` - will create your project in the folder `built` 5. `mv built {yourPath}/{yourProjectName}` - to move your project wherever you want diff --git a/exporter/Exporter.php b/exporter/Exporter.php index c98cbc1..482759f 100644 --- a/exporter/Exporter.php +++ b/exporter/Exporter.php @@ -62,12 +62,12 @@ * * @pModule Module's name * @pVersion Module's version - * @pDep TRUE if dependency + * @pDep dependency level * * @return err_msg Error message | TRUE (if all is ok) * */ - public function enable($pModule=null, $pVersion=null, $pDep=false){ + public function enable($pModule=null, $pVersion=null, $pDep=0){ /* [1] Module management =========================================================*/ @@ -141,17 +141,19 @@ /* (5) If not a dependency or higher version -> set/update version */ - if( !$pDep || $this->lower($module, $this->modules['enabled'][$mname], $vname) ){ + if( $pDep == 0 || $this->lower($module, $this->modules['enabled'][$mname], $vname) ){ // if a dependency, set new params - if( $pDep ) - echo " [x] $mname:$vname (version $vname+ required)\n"; + if( $pDep > 0 ) + echo str_repeat(" ", $pDep)."[x] $mname:$vname ($mname:$vname+ required)\n"; + else + echo str_repeat(" ", $pDep)."[x] $mname:$vname\n"; - // else, store new module + // in any case -> store new module's version $this->modules['enabled'][$mname] = $vname; - }else if( $pDep ) - echo " [x] $mname:".$this->modules['enabled'][$mname]." (version $vname+ required)\n"; + }else if( $pDep > 0 ) + echo str_repeat(" ", $pDep)."[x] $mname:".$this->modules['enabled'][$mname]." ($mname:$vname+ required)\n"; /* [4] Loading dependencies @@ -159,10 +161,11 @@ /* (1) Loading each dependency */ if( count($version) > 0 ){ + echo "\n".str_repeat(" ", $pDep); echo "dependencies:\n"; foreach($version as $depMod=>$depVer) - $enabled = $this->enable($depMod, $depVer, true); + $enabled = $this->enable($depMod, $depVer, $pDep+1); } diff --git a/exporter/main.php b/exporter/main.php index cf13023..8170edc 100644 --- a/exporter/main.php +++ b/exporter/main.php @@ -55,7 +55,7 @@ /* (2) Enables a module and its version ---------------------------------------------------------*/ - case 'enable': { + case 'install': { if( $arglen < 2 || !preg_match("/^(.+):([0-9\.-]+)$/i", $arguments[1], $matches) ){ echo "You must specify @module:@version.\n"; @@ -72,7 +72,7 @@ /* (3) Disabled a module ---------------------------------------------------------*/ - case 'disable': { + case 'remove': { if( $arglen < 2 ){ echo "You must specify @module.\n"; diff --git a/exporter/modules.json b/exporter/modules.json index 7a02dc8..94ac98f 100644 --- a/exporter/modules.json +++ b/exporter/modules.json @@ -36,8 +36,10 @@ } }, "enabled": { - "api": "2.0", + "orm": "0.8.2", + "database": "2.0", "error": "2.0", - "database": "2.0" + "api": "2.0", + "router": "1.0" } } \ No newline at end of file diff --git a/xdrm-framework b/xdrm-framework new file mode 100755 index 0000000..ca707dd --- /dev/null +++ b/xdrm-framework @@ -0,0 +1,2 @@ +#!/bin/sh +php exporter/main.php $*