Implement packager and installer hooks
[pharext/pharext] / src / pharext_install.tpl.php
diff --git a/src/pharext_install.tpl.php b/src/pharext_install.tpl.php
new file mode 100644 (file)
index 0000000..9bf8271
--- /dev/null
@@ -0,0 +1,36 @@
+<?='<?php'?>
+
+/**
+ * Generated by pharext v<?=pharext\VERSION?> at <?=date("Y-m-d H:i:i T")?>.
+ */
+namespace pharext;
+
+return function(Installer $installer) {
+       $args = $installer->getArgs();
+       <?php foreach ($configure as $cfg) : ?>
+       
+       $args->compile([[
+               null, 
+               "<?=$cfg["name"]?>", 
+               "<?=ucfirst($cfg["prompt"])?>", 
+               CliArgs::OPTARG,
+               <?php if (strlen($cfg["default"])) : ?>
+               "<?=$cfg["default"]?>"
+               <?php else : ?>
+               NULL
+               <?php endif; ?>
+               
+       ]]);
+       <?php endforeach; ?>
+       
+       return function(Installer $installer) {
+               $args = $installer->getArgs();
+               <?php foreach ($configure as $cfg) : ?>
+               
+               if (isset($args["<?=$cfg["name"]?>"])) {
+                       $args->configure = "--<?=$cfg["name"]?>=".$args["<?=$cfg["name"]?>"];
+               }
+               <?php endforeach; ?>
+               
+       };
+};