Skip to content

Commit

Permalink
Moved help from commands configure() to getHelp()
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel authored and cmuench committed Jul 15, 2024
1 parent 559dcd3 commit 85a3b88
Show file tree
Hide file tree
Showing 41 changed files with 369 additions and 168 deletions.
9 changes: 7 additions & 2 deletions src/N98/Magento/Command/Cache/CleanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ protected function configure()
)
->setDescription('Clean magento cache')
;
}

$help = <<<HELP
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
Cleans expired cache entries.
If you would like to clean only one cache type use like:
Expand All @@ -48,7 +54,6 @@ protected function configure()
--reinit Reinitialise the config cache after cleaning (Default)
--no-reinit Don't reinitialise the config cache after cleaning
HELP;
$this->setHelp($help);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/N98/Magento/Command/Cache/FlushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ protected function configure()
)
->setDescription('Flush magento cache storage')
;
}

$help = <<<HELP
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
Flush the entire cache.
$ n98-magerun.phar cache:flush [--reinit --no-reinit]
Expand All @@ -39,7 +45,6 @@ protected function configure()
--reinit Reinitialise the config cache after flushing (Default)
--no-reinit Don't reinitialise the config cache after flushing
HELP;
$this->setHelp($help);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/N98/Magento/Command/Config/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ protected function configure()
)
->addOption('all', null, InputOption::VALUE_NONE, 'Delete all entries by path')
;
}

$help = <<<HELP
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
To delete all entries of a path you can set the option --all.
HELP;
$this->setHelp($help);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/N98/Magento/Command/Config/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ protected function configure()
->addArgument('xpath', InputArgument::OPTIONAL, 'XPath to filter XML output', null)
->setDescription('Dump merged xml config')
;
}

$help = <<<HELP
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
Dumps merged XML configuration to stdout. Useful to see all the XML.
You can filter the XML with first argument.
Expand All @@ -38,7 +44,6 @@ protected function configure()
$ n98-magerun.phar config:dump > extern_file.xml
HELP;
$this->setHelp($help);
}

/**
Expand Down
28 changes: 14 additions & 14 deletions src/N98/Magento/Command/Config/GetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ protected function configure()
$this
->setName('config:get')
->setDescription('Get a core config item')
->setHelp(
<<<EOT
If <info>path</info> is not set, all available config items will be listed.
The <info>path</info> may contain wildcards (*).
If <info>path</info> ends with a trailing slash, all child items will be listed. E.g.
config:get web/
is the same as
config:get web/*
EOT
)
->addArgument('path', InputArgument::OPTIONAL, 'The config path')
->addOption(
'scope',
Expand All @@ -45,11 +34,22 @@ protected function configure()
->addOption('update-script', null, InputOption::VALUE_NONE, 'Output as update script lines')
->addOption('magerun-script', null, InputOption::VALUE_NONE, 'Output for usage with config:set')
->addFormatOption();
}

$help = <<<HELP
If path is not set, all available config items will be listed. path may contain wildcards (*)
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
If <info>path</info> is not set, all available config items will be listed.
The <info>path</info> may contain wildcards (*).
If <info>path</info> ends with a trailing slash, all child items will be listed. E.g.
config:get web/
is the same as
config:get web/*
HELP;
$this->setHelp($help);
}

/**
Expand Down
15 changes: 10 additions & 5 deletions src/N98/Magento/Command/Config/SearchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ protected function configure()
$this
->setName('config:search')
->setDescription('Search system configuration descriptions.')
->setHelp(
<<<EOT
Searches the merged system.xml configuration tree <labels/> and <comments/> for the indicated text.
EOT
)
->addArgument('text', InputArgument::REQUIRED, 'The text to search for');
}

/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
Searches the merged system.xml configuration tree <labels/> and <comments/> for the indicated text.
HELP;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
Expand Down
10 changes: 7 additions & 3 deletions src/N98/Magento/Command/Config/SetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ protected function configure()
"Do not treat value NULL as " . self::DISPLAY_NULL_UNKNOWN_VALUE . " value"
)
;
}

$help = <<<HELP
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
Set a store config value by path.
To set a value of a specify store view you must set the "scope" and "scope-id" option.
HELP;
$this->setHelp($help);
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/N98/Magento/Command/Customer/ChangePasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ protected function configure()
->addArgument('website', InputArgument::OPTIONAL, 'Website of the customer')
->setDescription('Changes the password of a customer.')
;
}

$help = <<<HELP
- Website parameter must only be given if more than one websites are available.
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
Website parameter must only be given if more than one websites are available.
HELP;
$this->setHelp($help);
}

/**
Expand Down
39 changes: 22 additions & 17 deletions src/N98/Magento/Command/Customer/CreateDummyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,28 @@ class CreateDummyCommand extends AbstractCustomerCommand
{
protected function configure()
{
$help = <<<HELP
$this
->setName('customer:create:dummy')
->addArgument('count', InputArgument::REQUIRED, 'Count')
->addArgument('locale', InputArgument::REQUIRED, Locale::class)
->addArgument('website', InputArgument::OPTIONAL, 'Website')
->addOption(
'with-addresses',
null,
InputOption::VALUE_NONE,
'Create dummy billing/shipping addresses for each customers'
)
->setDescription('Generate dummy customers. You can specify a count and a locale.')
->addFormatOption()
;
}

/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
Supported Locales:
- cs_CZ
Expand All @@ -35,22 +56,6 @@ protected function configure()
- es_AR
- de_AT
HELP;

$this
->setName('customer:create:dummy')
->addArgument('count', InputArgument::REQUIRED, 'Count')
->addArgument('locale', InputArgument::REQUIRED, Locale::class)
->addArgument('website', InputArgument::OPTIONAL, 'Website')
->addOption(
'with-addresses',
null,
InputOption::VALUE_NONE,
'Create dummy billing/shipping addresses for each customers'
)
->setDescription('Generate dummy customers. You can specify a count and a locale.')
->addFormatOption()
->setHelp($help)
;
}

/**
Expand Down
11 changes: 7 additions & 4 deletions src/N98/Magento/Command/Customer/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ protected function configure()
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force delete')
->addOption('range', '-r', InputOption::VALUE_NONE, 'Delete a range of customers by Id')
->setDescription('Delete Customer/s');
}

$help = <<<HELP
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
This will delete a customer by a given Id/Email, delete all customers or delete all customers in a range of Ids.
<comment>Example Usage:</comment>
Expand All @@ -59,10 +65,7 @@ protected function configure()
n98-magerun customer:delete [email protected] <info># Will delete customer with that email</info>
n98-magerun customer:delete --all <info># Will delete all customers</info>
n98-magerun customer:delete --range <info># Will prompt for start and end Ids for batch deletion</info>
HELP;

$this->setHelp($help);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/N98/Magento/Command/Customer/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ protected function configure()
->addFormatOption()
->setDescription('Lists customers')
;
}

$help = <<<HELP
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
List customers. The output is limited to 1000 (can be changed by overriding config).
If search parameter is given the customers are filtered (searchs in firstname, lastname and email).
HELP;
$this->setHelp($help);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/N98/Magento/Command/Database/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ protected function configure()
->setName('db:create')
->setDescription('Create currently configured database')
;
}

$help = <<<HELP
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
The command tries to create the configured database according to your
settings in app/etc/local.xml.
The configured user must have "CREATE DATABASE" privileges on MySQL Server.
HELP;
$this->setHelp($help);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/N98/Magento/Command/Database/DropCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ protected function configure()
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force')
->setDescription('Drop current database')
;
}

$help = <<<HELP
/**
* {@inheritdoc}
*/
public function getHelp(): string
{
return <<<HELP
The command prompts before dropping the database. If --force option is specified it
directly drops the database.
The configured user in app/etc/local.xml must have "DROP" privileges.
HELP;
$this->setHelp($help);
}

/**
Expand Down
21 changes: 11 additions & 10 deletions src/N98/Magento/Command/Database/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@ protected function configure()
'Specify local.xml connection node, default to default_setup'
)
->setDescription('Dumps database with mysqldump cli client');
}

/**
* {@inheritdoc}
*/
public function getHelp(): string
{
$help = <<<HELP
Dumps configured magento database with `mysqldump`. You must have installed
the MySQL client tools.
Expand All @@ -147,7 +153,7 @@ protected function configure()
The command reads app/etc/local.xml to find the correct settings.
See it in action: http://youtu.be/ttjZHY6vThs
See it in action: https://youtu.be/ttjZHY6vThs
- If you like to prepend a timestamp to the dump name the --add-time option
can be used.
Expand All @@ -156,7 +162,10 @@ protected function configure()
to dump directly in gzip compressed file.
HELP;
$this->setHelp($help);
return
$help . PHP_EOL
. $this->getCompressionHelp() . PHP_EOL
. $this->getTableDefinitionHelp();
}

/**
Expand Down Expand Up @@ -238,14 +247,6 @@ public function getTableDefinitionHelp()
return $messages;
}

public function getHelp()
{
return
parent::getHelp() . PHP_EOL
. $this->getCompressionHelp() . PHP_EOL
. $this->getTableDefinitionHelp();
}

/**
* @param InputInterface $input
* @param OutputInterface $output
Expand Down
Loading

0 comments on commit 85a3b88

Please sign in to comment.