22
33namespace App \Commands \Foundation ;
44
5- use Illuminate \Foundation \Console \ConsoleMakeCommand as ConsoleMake ;
65use App \Commands \Helpers \PackageDetail ;
6+ use Illuminate \Console \GeneratorCommand ;
7+ use Symfony \Component \Console \Input \InputOption ;
8+ use Symfony \Component \Console \Input \InputArgument ;
79
8- class ConsoleMakeCommand extends ConsoleMake
10+ class ConsoleMakeCommand extends GeneratorCommand
911{
1012 use PackageDetail;
13+
1114 /**
12- * The console command name.
13- *
14- * @var string
15- */
15+ * The console command name.
16+ *
17+ * @var string
18+ */
1619 protected $ name = 'make:command ' ;
1720
1821 /**
@@ -22,6 +25,62 @@ class ConsoleMakeCommand extends ConsoleMake
2225 */
2326 protected $ description = 'Create a new Artisan command ' ;
2427
28+ /**
29+ * The type of class being generated.
30+ *
31+ * @var string
32+ */
33+ protected $ type = 'Console command ' ;
34+
35+ /**
36+ * Replace the class name for the given stub.
37+ *
38+ * @param string $stub
39+ * @param string $name
40+ * @return string
41+ */
42+ protected function replaceClass ($ stub , $ name )
43+ {
44+ $ stub = parent ::replaceClass ($ stub , $ name );
45+
46+ return str_replace (['dummy:command ' , '{{ command }} ' ], $ this ->option ('command ' ), $ stub );
47+ }
48+
49+ /**
50+ * Get the default namespace for the class.
51+ *
52+ * @param string $rootNamespace
53+ * @return string
54+ */
55+ protected function getDefaultNamespace ($ rootNamespace )
56+ {
57+ return $ rootNamespace . '\Console\Commands ' ;
58+ }
59+
60+ /**
61+ * Get the console command arguments.
62+ *
63+ * @return array
64+ */
65+ protected function getArguments ()
66+ {
67+ return [
68+ ['name ' , InputArgument::REQUIRED , 'The name of the command ' ],
69+ ];
70+ }
71+
72+ /**
73+ * Get the console command options.
74+ *
75+ * @return array
76+ */
77+ protected function getOptions ()
78+ {
79+ return [
80+ ['command ' , null , InputOption::VALUE_OPTIONAL , 'The terminal command that should be assigned ' , 'command:name ' ],
81+ ];
82+ }
83+
2584 /**
2685 * Get the stub file for the generator.
2786 *
0 commit comments