1717use Inhere \Console \Util \Helper ;
1818use Inhere \Console \Util \Show ;
1919use RuntimeException ;
20+ use Toolkit \PFlag \FlagsParser ;
2021use Toolkit \Stdlib \Str ;
2122use function basename ;
2223use function file_exists ;
@@ -77,8 +78,9 @@ protected function packConfigure(Input $input): void
7778 * --files Only pack the list files to the exist phar, multi use ',' split
7879 * --no-progress bool;Disable output progress on the runtime
7980 *
80- * @param Input $input
81+ * @param Input $input
8182 * @param Output $output
83+ * @param FlagsParser $fs
8284 *
8385 * @return int
8486 * @throws Exception
@@ -92,16 +94,16 @@ protected function packConfigure(Input $input): void
9294 * only update the input files:
9395 * php -d phar.readonly=0 {binFile} phar:pack -o=mycli.phar --debug --files app/Command/ServeCommand.php
9496 */
95- public function packCommand (Input $ input , Output $ output ): int
97+ public function packCommand (Input $ input , Output $ output, FlagsParser $ fs ): int
9698 {
9799 $ startAt = microtime (true );
98100 $ workDir = $ input ->getPwd ();
99101
100- $ dir = $ input ->getOpt ('dir ' ) ?: $ workDir ;
102+ $ dir = $ fs ->getOpt ('dir ' ) ?: $ workDir ;
101103 $ cpr = $ this ->configCompiler ($ dir );
102104
103- $ refresh = $ input -> boolOpt ('refresh ' );
104- $ outFile = $ input -> getSameStringOpt ([ ' o ' , ' output '] , $ this ->defPkgName );
105+ $ refresh = $ fs -> getOpt ('refresh ' );
106+ $ outFile = $ fs -> getOpt ( ' output ' , $ this ->defPkgName );
105107 $ pharFile = $ workDir . '/ ' . $ outFile ;
106108
107109 Show::aList ([
@@ -111,13 +113,13 @@ public function packCommand(Input $input, Output $output): int
111113 ], 'Building Information ' );
112114
113115 // use fast build
114- if ($ this -> input -> boolOpt ('fast ' )) {
116+ if ($ fs -> getOpt ('fast ' )) {
115117 $ cpr ->setModifies ($ cpr ->findChangedByGit ());
116118 $ this ->output ->liteNote ('Use fast build, will only pack changed or new files(from git status) ' );
117119 }
118120
119121 // Manual append some files
120- if ($ files = $ input -> getStringOpt ('files ' )) {
122+ if ($ files = $ fs -> getOpt ('files ' )) {
121123 $ cpr ->setModifies (Str::explode ($ files ));
122124 $ output ->liteInfo ("will only pack input files to the exists phar: $ outFile " );
123125 }
@@ -130,7 +132,10 @@ public function packCommand(Input $input, Output $output): int
130132 });
131133
132134 $ output ->colored ('Collect Pack files ' , 'comment ' );
133- $ this ->outputProgress ($ cpr , $ input );
135+
136+ if (!$ fs ->getOpt ('no-progress ' )) {
137+ $ this ->outputProgress ($ cpr );
138+ }
134139
135140 // packing ...
136141 $ cpr ->pack ($ pharFile , $ refresh );
@@ -178,17 +183,12 @@ protected function configCompiler(string $dir): PharCompiler
178183
179184 /**
180185 * @param PharCompiler $cpr
181- * @param Input $input
182186 *
183187 * @return void
184188 */
185- private function outputProgress (PharCompiler $ cpr, Input $ input ): void
189+ private function outputProgress (PharCompiler $ cpr ): void
186190 {
187- if ($ input ->getBoolOpt ('no-progress ' )) {
188- return ;
189- }
190-
191- if ($ input ->getOpt ('debug ' )) {
191+ if ($ this ->isDebug ()) {
192192 // $output->info('Pack file to Phar ... ...');
193193 $ cpr ->onAdd (function (string $ path ) {
194194 $ this ->writeln (" <info>+</info> $ path " );
@@ -228,15 +228,16 @@ public function setCompilerConfiger(Closure $compilerConfiger): void
228228 * -y, --yes bool;Whether display goon tips message.
229229 * --overwrite bool;Whether overwrite exists files on extract phar
230230 *
231- * @param Input $in
231+ * @param Input $in
232232 * @param Output $out
233+ * @param FlagsParser $fs
233234 *
234235 * @return int
235236 * @example {fullCommand} -f myapp.phar -d var/www/app
236237 */
237- public function unpackCommand ($ in , $ out ): int
238+ public function unpackCommand (Input $ in , Output $ out, FlagsParser $ fs ): int
238239 {
239- if (!$ path = $ in -> getSameOpt ([ ' f ' , ' file '] )) {
240+ if (!$ path = $ fs -> getOpt ( ' file ' )) {
240241 return $ out ->error ("Please input the phar file path by option '-f|--file' " );
241242 }
242243
@@ -247,8 +248,8 @@ public function unpackCommand($in, $out): int
247248 return $ out ->error ("The phar file not exists. File: $ file " );
248249 }
249250
250- $ dir = $ in -> getSameOpt ([ ' d ' , ' dir '] ) ?: $ basePath ;
251- $ overwrite = $ in -> getBoolOpt ('overwrite ' );
251+ $ dir = $ fs -> getOpt ( ' dir ' ) ?: $ basePath ;
252+ $ overwrite = $ fs -> getOpt ('overwrite ' );
252253
253254 if (!is_dir ($ dir )) {
254255 Helper::mkdir ($ dir );
0 commit comments