From 38ab50963047d80f5754f307d3c5c91fdd4177da Mon Sep 17 00:00:00 2001 From: Netkas Date: Fri, 29 Sep 2023 16:43:48 -0400 Subject: [PATCH] Added shadow copy command to the Package Inspector Command --- .../CLI/Commands/PackageInspectorCommand.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/ncc/CLI/Commands/PackageInspectorCommand.php b/src/ncc/CLI/Commands/PackageInspectorCommand.php index c903e8b..c98c8c3 100644 --- a/src/ncc/CLI/Commands/PackageInspectorCommand.php +++ b/src/ncc/CLI/Commands/PackageInspectorCommand.php @@ -117,6 +117,19 @@ } } + if(isset($args['copy']) || isset($args['o'])) + { + try + { + return self::copyPackage($args); + } + catch(Exception $e) + { + Console::outException(sprintf('Failed to copy package: %s', $e->getMessage()), $e, 1); + return 1; + } + } + return self::displayOptions(); } @@ -263,6 +276,21 @@ Console::out(Yaml::dump($data, 4, 2), false); } + /** + * Saves a shadow copy of the package to the specified path + * + * @param array $args + * @return int + * @throws IOException + */ + private static function copyPackage(array $args): int + { + $package_reader = new PackageReader($args['path'] ?? $args['p']); + $package_reader->saveCopy($args['copy'] ?? $args['o']); + + return 0; + } + /** * Displays the main options section * @@ -280,6 +308,7 @@ new CliHelpSection(['assembly'], 'Prints out the assembly information of the package'), new CliHelpSection(['dependencies'], 'Prints out the dependencies of the package'), new CliHelpSection(['execution_units'], 'Prints out the execution units of the package'), + new CliHelpSection(['copy', '-o'], 'Writes a shadow copy of the package to the specified path'), ]; $options_padding = Functions::detectParametersPadding($options) + 4;