22
33namespace Drupal \features \Commands ;
44
5+ use Consolidation \OutputFormatters \StructuredData \ListDataFromKeys ;
6+ use Consolidation \OutputFormatters \StructuredData \PropertyList ;
57use Consolidation \OutputFormatters \StructuredData \RowsOfFields ;
68use Drupal \Component \Diff \DiffFormatter ;
79use Drupal \config_update \ConfigDiffInterface ;
@@ -146,21 +148,22 @@ public function status($keys = NULL, array $options = ['bundle' => NULL]) {
146148 $ currentBundle = $ this ->assigner ->getBundle ();
147149 $ export_settings = $ this ->manager ->getExportSettings ();
148150 $ methods = $ this ->assigner ->getEnabledAssigners ();
151+ $ output = $ this ->output ();
149152 if ($ currentBundle ->isDefault ()) {
150- $ this -> output () ->writeln (dt ('Current bundle: none ' ));
153+ $ output ->writeln (dt ('Current bundle: none ' ));
151154 }
152155 else {
153- $ this -> output () ->writeln (dt ('Current bundle: @name (@machine_name) ' , [
156+ $ output ->writeln (dt ('Current bundle: @name (@machine_name) ' , [
154157 '@name ' => $ currentBundle ->getName (),
155158 '@machine_name ' => $ currentBundle ->getMachineName (),
156159 ]));
157160 }
158- $ this -> output () ->writeln (dt ('Export folder: @folder ' , [
161+ $ output ->writeln (dt ('Export folder: @folder ' , [
159162 '@folder ' => $ export_settings ['folder ' ],
160163 ]));
161- $ this -> output ()
164+ $ output
162165 ->writeln (dt ('The following assignment methods are enabled: ' ));
163- $ this -> output () ->writeln (dt (' @methods ' , [
166+ $ output ->writeln (dt (' @methods ' , [
164167 '@methods ' => implode (', ' , array_keys ($ methods )),
165168 ]));
166169
@@ -170,7 +173,7 @@ public function status($keys = NULL, array $options = ['bundle' => NULL]) {
170173 $ data = count ($ keys ) > 1
171174 ? array_keys ($ config )
172175 : $ config [$ keys [0 ]];
173- $ this -> output () ->writeln (print_r ($ data , TRUE ));
176+ $ output ->writeln (print_r ($ data , TRUE ));
174177 }
175178 }
176179
@@ -192,14 +195,15 @@ public function status($keys = NULL, array $options = ['bundle' => NULL]) {
192195 *
193196 * @option bundle Use a specific bundle namespace.
194197 *
195- * @usage drush features- list - packages
198+ * @usage drush features: list: packages
196199 * Display a list of all existing features and packages available to be
197200 * generated.
198- * @usage drush features- list- packages 'example_article'
201+ * @usage drush features: list: packages 'example_article'
199202 * Display a list of all configuration objects assigned to the
200203 * 'example_article' package.
201204 *
202205 * @field-labels
206+ * config: Config
203207 * name: Name
204208 * machine_name: Machine name
205209 * status: Status
@@ -245,15 +249,24 @@ public function listPackages(
245249 }
246250 return new RowsOfFields ($ result );
247251 }
248- // If a valid package was listed, list its configuration.
249- else {
250- // @todo. I suggest changing this command to return YAML with config as nested values.
251- }
252+
253+ // A valid package was listed.
254+ $ package = $ this ->manager ->findPackage ($ package_name );
252255
253256 // If no matching package found, return an error.
254- $ this ->logger ()->warning (dt ('Package "@package" not found. ' ,
255- ['@package ' => $ package_name ]));
256- return FALSE ;
257+ if (empty ($ package )) {
258+ $ this ->logger ()->warning (dt ('Package "@package" not found. ' , [
259+ '@package ' => $ package_name ,
260+ ]));
261+ return FALSE ;
262+ }
263+
264+ // This is a valid package, list its configuration.
265+ $ config = array_map (function ($ name ) {
266+ return ['config ' => $ name ];
267+ }, $ package ->getConfig ());
268+
269+ return new RowsOfFields ($ config );
257270 }
258271
259272 /**
0 commit comments