Implement stow config file and folder unwrapping
Move includes to their own folder, config.php will otherwise be included and cleans up nicely
This commit is contained in:
16
php/bin/stow
16
php/bin/stow
@ -1,12 +1,13 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../argvParser.php';
|
||||
require_once __DIR__ . '/../functions.php';
|
||||
require_once __DIR__ . '/../stow.php';
|
||||
require_once __DIR__ . '/../includes/argvParser.php';
|
||||
require_once __DIR__ . '/../includes/functions.php';
|
||||
require_once __DIR__ . '/../includes/stow.php';
|
||||
require_once __DIR__ . '/../includes/config.php';
|
||||
|
||||
$argvParser = new ArgvParser(
|
||||
['u' => 'Unstow files', 'b' => 'Backup existing files', 'f' => 'Force overwrite'],
|
||||
['u' => 'Unstow files', 'b' => 'Backup existing files', 'f' => 'Force overwrite', 'w' => 'Unwrap folders'],
|
||||
['stow-directory' => 'The directory to stow']
|
||||
);
|
||||
$parsed = $argvParser->parseArgv($argv);
|
||||
@ -19,17 +20,20 @@ $cwd = getcwd();
|
||||
$action = $parsed->get('u') ? stow::ACTION_UNSTOW : stow::ACTION_STOW;
|
||||
$backup = $parsed->get('b');
|
||||
$force = $parsed->get('f');
|
||||
$unwrap = $parsed->get('w');
|
||||
|
||||
$stowName = $parsed->get('stow-directory');
|
||||
$stowPath = path($cwd, $stowName);
|
||||
$targetPath = dirname($stowPath, 2);
|
||||
|
||||
$config = new config($stowPath);
|
||||
$targetPath = $config->get('targetPath', dirname($stowPath, 2));
|
||||
|
||||
if (!is_dir($stowPath)) {
|
||||
line("Directory '$stowName' does not exist");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$stow = new stow($action, $backup, $force);
|
||||
$stow = new stow($action, $backup, $force, $unwrap);
|
||||
$stow->run($stowPath, $targetPath);
|
||||
|
||||
exit(0);
|
Reference in New Issue
Block a user