-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance dcf generator so it can port old Drush commandfiles (#2794)
- Loading branch information
Showing
4 changed files
with
111 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/Commands/generate/Generators/Drush/default-methods.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Command description here. | ||
* | ||
* @command {{ machine_name }}-commandName | ||
* @param $arg1 Argument description. | ||
* @option option-name option description | ||
* @usage {{ machine_name }}-commandName foo | ||
* Usage description | ||
* @aliases foo | ||
*/ | ||
public function commandName($arg1, $options = ['option-name' => 'default']) { | ||
$this->logger()->success(dt('Achievement unlocked.')); | ||
} | ||
|
||
/** | ||
* An example of the table output format. | ||
* | ||
* @command {{ machine_name }}-token | ||
* @aliases token | ||
* @field-labels | ||
* group: Group | ||
* token: Token | ||
* name: Name | ||
* @default-fields group,token,name | ||
* | ||
* @return \Consolidation\OutputFormatters\StructuredData\RowsOfFields | ||
*/ | ||
public function token($options = ['format' => 'table']) { | ||
$all = \Drupal::token()->getInfo(); | ||
foreach ($all['tokens'] as $group => $tokens) { | ||
foreach ($tokens as $key => $token) { | ||
$rows[] = [ | ||
'group' => $group, | ||
'token' => $key, | ||
'name' => $token['name'], | ||
]; | ||
} | ||
} | ||
return new RowsOfFields($rows); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Commands/generate/Generators/Drush/ported-methods.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{% for key, command in commands %} | ||
/** | ||
* {{ command.description|raw }} | ||
* | ||
* @command {{ key }} | ||
{% for argName, argDescription in command.arguments %} | ||
* @param {{ argName }} {{ argDescription|raw }} | ||
{% endfor %} | ||
{% for optionName, optionDescription in command.options %} | ||
* @option {{ optionName }} {{ optionDescription|raw }} | ||
{% endfor %} | ||
{% for usageName, usageDescription in command.examples %} | ||
* @usage {{ usageName|raw }} | ||
* {{ usageDescription|raw }} | ||
{% endfor %} | ||
* @aliases {{ command.aliases|join(',') }} | ||
*/ | ||
public function {{ command.method }}({{ command.argumentsConcat|raw }}{{ command.optionsConcat|raw }}) { | ||
|
||
} | ||
|
||
{% endfor %} |