Skip to content

Commit 47545df

Browse files
committed
DD#main: feat: replace magepath with cwd
1 parent fe73773 commit 47545df

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ chmod +x magegen.php
1616
### Download the phar
1717

1818
```
19-
curl -o magegen.phar https://github.com/Skywire/MageGen/releases/latest/download/magegen.phar
19+
curl -o -L magegen.phar https://github.com/Skywire/MageGen/releases/latest/download/magegen.phar
2020
chmod +x magegen.phar
2121
sudo mv magegen.phar /usr/local/bin/magegen
2222
```
2323

2424
## Usage
2525

26-
### Commands
26+
Run from inside a Magento 2 project directory.
2727

28-
All commands expect magepath as the first argument this is the path to the magento 2 installation.
28+
`magegen --help`
2929

30-
If omitted the current working directory will be used.
30+
### Commands
3131

3232
#### Make Module
3333

3434
Create a new Magento module with registration and etc/module.xml files
3535

36-
`./magegen.php make:module <magepath> [<namespace> [<module>]]`
36+
`./magegen.php make:module [<namespace> [<module>]]`
3737

3838
* vendor - The vendor namespace e.g MyCompanyName
3939
* module - The module name, e.g MyModuleName
@@ -44,7 +44,7 @@ Create or update a plugin class.
4444

4545
You can update an existing plugin to add new methods.
4646

47-
`./magegen.php make:plugin <magepath> [<subject> [<method> [<class> [<type> [<area>]]]]]`
47+
`./magegen.php make:plugin [<subject> [<method> [<class> [<type> [<area>]]]]]`
4848

4949
* subject - The plugin subject class or interface, e.g \Magento\Checkout\Api\PaymentInformationManagementInterface
5050
* method - The plugin subject method e.g. savePaymentInformationAndPlaceOrder
@@ -60,7 +60,7 @@ Create or update a CRUD entity model, with API interface, resource model and col
6060
When updating a model you can add new properties, this will add the getters and setters to the interface and the model
6161
class.
6262

63-
`./magegen.php make:entity <magepath> [<module> [<entity> [<table> [<id>]]]]`
63+
`./magegen.php make:entity [<module> [<entity> [<table> [<id>]]]]`
6464

6565
* module - The module name, e.g. MyCompany_MyModule
6666
* entity - The entity model name
@@ -71,7 +71,7 @@ class.
7171

7272
Creates a repository and search result model with interfaces.
7373

74-
`./magegen.php make:repository <magepath> [<module> [<entity> [<table> [<id>]]]]`
74+
`./magegen.php make:repository [<module> [<entity> [<table> [<id>]]]]`
7575

7676
* module - The module name, e.g. MyCompany_MyModule
7777
* entity - The entity model name
@@ -82,7 +82,7 @@ Create or update db_schema.xml.
8282

8383
Will create entity table with primary key constraint, does not overwrite existing tables
8484

85-
`./magegen.php make:schema [<magepath> [<module> [<entity>]]]`
85+
`./magegen.php make:schema [[<module> [<entity>]]]`
8686

8787
* module - The module name, e.g. MyCompany_MyModule
8888
* entity - The entity model name

src/AbstractCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Console\Command\Command;
2020
use Symfony\Component\Console\Input\InputArgument;
2121
use Symfony\Component\Console\Input\InputInterface;
22+
use Symfony\Component\Console\Input\InputOption;
2223
use Twig\Environment;
2324

2425

@@ -57,11 +58,11 @@ public function __construct(Environment $twig, string $name = null)
5758

5859
protected function configure(): void
5960
{
60-
$this->addArgument('magepath', InputArgument::OPTIONAL, '', getcwd());
61+
$this->addOption('magepath', '-m', InputOption::VALUE_REQUIRED, 'Path to Magento installation', getcwd());
6162
}
6263

6364
protected function getWriter(InputInterface $input)
6465
{
65-
return new ModuleFile($input->getArgument('magepath'));
66+
return new ModuleFile($input->getOption('magepath'));
6667
}
6768
}

src/MakeEntityCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function configure(): void
7979

8080
protected function execute(InputInterface $input, OutputInterface $output): int
8181
{
82-
require $input->getArgument('magepath') . '/vendor/autoload.php';
82+
require $input->getOption('magepath') . '/vendor/autoload.php';
8383

8484
$writer = $this->getWriter($input);
8585
$io = new SymfonyStyle($input, $output);
@@ -89,7 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8989
$module = $io->askQuestion(
9090
(new Question('Module'))->setAutocompleterValues(
9191
(new ModuleAutocomplete())->getAutocompleteValues(
92-
$input->getArgument('magepath')
92+
$input->getOption('magepath')
9393
)
9494
)
9595
);
@@ -101,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
101101
$entity = $io->askQuestion(
102102
(new Question(sprintf('Entity %s', $prefix)))->setAutocompleterValues(
103103
(new EntityAutocomplete())->getAutocompleteValues(
104-
$input->getArgument('magepath'),
104+
$input->getOption('magepath'),
105105
$module
106106
)
107107
)
@@ -125,7 +125,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
125125
}
126126

127127
if ($isAmend) {
128-
$classWriter = new ClassFile($input->getArgument('magepath'));
128+
$classWriter = new ClassFile($input->getOption('magepath'));
129129

130130
$io->title('Class exists, adding new properties');
131131

src/MakePluginCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ protected function configure(): void
7272

7373
protected function execute(InputInterface $input, OutputInterface $output): int
7474
{
75-
require $input->getArgument('magepath') . '/vendor/autoload.php';
75+
require $input->getOption('magepath') . '/vendor/autoload.php';
7676

7777
$writer = $this->getWriter($input);
78-
$classWriter = new ClassFile($input->getArgument('magepath'));
78+
$classWriter = new ClassFile($input->getOption('magepath'));
7979

8080
$io = new SymfonyStyle($input, $output);
8181

src/MakeRepositoryCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function configure(): void
7777

7878
protected function execute(InputInterface $input, OutputInterface $output): int
7979
{
80-
require $input->getArgument('magepath') . '/vendor/autoload.php';
80+
require $input->getOption('magepath') . '/vendor/autoload.php';
8181

8282
$io = new SymfonyStyle($input, $output);
8383

@@ -86,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8686
$module = $io->askQuestion(
8787
(new Question('Module'))->setAutocompleterValues(
8888
(new ModuleAutocomplete())->getAutocompleteValues(
89-
$input->getArgument('magepath')
89+
$input->getOption('magepath')
9090
)
9191
)
9292
);
@@ -98,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9898
$entity = $io->askQuestion(
9999
(new Question(sprintf('Entity %s', $prefix)))->setAutocompleterValues(
100100
(new EntityAutocomplete())->getAutocompleteValues(
101-
$input->getArgument('magepath'),
101+
$input->getOption('magepath'),
102102
$module
103103
)
104104
)

src/MakeSchemaCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function configure(): void
7272

7373
protected function execute(InputInterface $input, OutputInterface $output): int
7474
{
75-
require $input->getArgument('magepath') . '/vendor/autoload.php';
75+
require $input->getOption('magepath') . '/vendor/autoload.php';
7676

7777
$io = new SymfonyStyle($input, $output);
7878

@@ -81,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8181
$module = $io->askQuestion(
8282
(new Question('Module'))->setAutocompleterValues(
8383
(new ModuleAutocomplete())->getAutocompleteValues(
84-
$input->getArgument('magepath')
84+
$input->getOption('magepath')
8585
)
8686
)
8787
);
@@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9393
$entity = $io->askQuestion(
9494
(new Question(sprintf('Entity %s', $prefix)))->setAutocompleterValues(
9595
(new EntityAutocomplete())->getAutocompleteValues(
96-
$input->getArgument('magepath'),
96+
$input->getOption('magepath'),
9797
$module
9898
)
9999
)

0 commit comments

Comments
 (0)