From c4beef7d91f4cb361a1154f562b7a380f04007c4 Mon Sep 17 00:00:00 2001 From: bilogic Date: Sun, 23 Aug 2020 23:03:01 +0800 Subject: [PATCH] accepts both ```vendor/name``` or ```vendor name``` (#110) Co-authored-by: bilogic <> --- src/Commands/NewPackage.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Commands/NewPackage.php b/src/Commands/NewPackage.php index 5ec8a1d..5ce3eb9 100644 --- a/src/Commands/NewPackage.php +++ b/src/Commands/NewPackage.php @@ -20,7 +20,7 @@ class NewPackage extends Command * The name and signature of the console command. * @var string */ - protected $signature = 'packager:new {vendor} {name} {--i} {--skeleton=}'; + protected $signature = 'packager:new {vendor} {name?} {--i} {--skeleton=}'; /** * The console command description. @@ -62,13 +62,22 @@ public function handle() // Start the progress bar $this->startProgressBar(6); + $vendor = $this->argument('vendor'); + $name = $this->argument('name'); + + if (stripos($vendor, "/") > 0) { + $part = explode("/", $vendor); + $vendor = $part[0]; + $name = $part[1]; + } + // Defining vendor/package, optionally defined interactively if ($this->option('i')) { - $this->conveyor->vendor($this->ask('What will be the vendor name?', $this->argument('vendor'))); - $this->conveyor->package($this->ask('What will be the package name?', $this->argument('name'))); + $this->conveyor->vendor($this->ask('What will be the vendor name?', $vendor)); + $this->conveyor->package($this->ask('What will be the package name?', $name)); } else { - $this->conveyor->vendor($this->argument('vendor')); - $this->conveyor->package($this->argument('name')); + $this->conveyor->vendor($vendor); + $this->conveyor->package($name); } // Start creating the package