public function unpackCommand($in, $out): int
    {
        if (!$path = $in->getSameOpt(['f', 'file'])) {
            return $out->error("Please input the phar file path by option '-f|--file'");
        }

        $basePath = $in->getPwd();
        $file = \realpath($basePath . '/' . $path);

        if (!\file_exists($file)) {
            return $out->error("The phar file not exists. File: $file");
        }

        $dir = $in->getSameOpt(['d', 'dir']) ?: $basePath;
        $overwrite = $in->getBoolOpt('overwrite');

        if (!\is_dir($dir)) {
            Helper::mkdir($dir);
        }

        $out->write("Now, begin extract phar file:\n $file \nto dir:\n $dir");

        PharCompiler::unpack($file, $dir, null, $overwrite);

        $out->success("OK, phar package have been extract to the dir: $dir");

        return 0;
    }
public function unpackCommand($in, $out): int
    {
        if (!$path = $in->getSameOpt(['f', 'file'])) {
            return $out->error("Please input the phar file path by option '-f|--file'");
        }

        $basePath = $in->getPwd();
        $file = \realpath($basePath . '/' . $path);

        if (!\file_exists($file)) {
            return $out->error("The phar file not exists. File: $file");
        }

        $dir = $in->getSameOpt(['d', 'dir']) ?: $basePath;
        $overwrite = $in->getBoolOpt('overwrite');

        if (!\is_dir($dir)) {
            Helper::mkdir($dir);
        }

        $out->write("Now, begin extract phar file:\n $file \nto dir:\n $dir");

        PharCompiler::unpack($file, $dir, null, $overwrite);

        $out->success("OK, phar package have been extract to the dir: $dir");

        return 0;
    }
public function unpackCommand ( $ in , $ out ) : int { if ( ! $ path = $ in -> getSameOpt ( [ 'f' , 'file' ] ) ) { return $ out -> error ( "Please input the phar file path by option '-f|--file'" ) ; } $ basePath = $ in -> getPwd ( ) ; $ file = \ realpath ( $ basePath . '/' . $ path ) ; if ( ! \ file_exists ( $ file ) ) { return $ out -> error ( "The phar file not exists. File: $file" ) ; } $ dir = $ in -> getSameOpt ( [ 'd' , 'dir' ] ) ? : $ basePath ; $ overwrite = $ in -> getBoolOpt ( 'overwrite' ) ; if ( ! \ is_dir ( $ dir ) ) { Helper :: mkdir ( $ dir ) ; } $ out -> write ( "Now, begin extract phar file:\n $file \nto dir:\n $dir" ) ; PharCompiler :: unpack ( $ file , $ dir , null , $ overwrite ) ; $ out -> success ( "OK, phar package have been extract to the dir: $dir" ) ; return 0 ; }
unpack a phar package to a directory
@usage {fullCommand} -f FILE [-d DIR]
@options
-f, --file STRING   The packed phar file path
-d, --dir STRING    The output dir on extract phar package.
-y, --yes BOOL      Whether display goon tips message.
--overwrite BOOL    Whether overwrite exists files on extract phar
@example {fullCommand} -f myapp.phar -d var/www/app
@param  \Inhere\Console\IO\Input  $in
@param  \Inhere\Console\IO\Output $out
@return int
unpack a phar package to a directory