@@ -233,6 +233,57 @@ public function listServices()
233233 return $ services ;
234234 }
235235
236+ /**
237+ * Find the service for the given service name.
238+ *
239+ * @param string $service
240+ *
241+ * @return \Lucid\Console\Components\Service
242+ */
243+ public function findService ($ service )
244+ {
245+ $ finder = new SymfonyFinder ();
246+ $ dirs = $ finder ->name ($ service )->in ($ this ->findServicesRootPath ())->directories ();
247+ if ($ dirs ->count () < 1 ) {
248+ throw new Exception ('Service " ' .$ service .'" could not be found. ' );
249+ }
250+
251+ foreach ($ dirs as $ dir ) {
252+ $ path = $ dir ->getRealPath ();
253+
254+ return new Service (Str::service ($ service ), $ path , $ this ->relativeFromReal ($ path ));
255+ }
256+ }
257+
258+ /**
259+ * Find the feature for the given feature name.
260+ *
261+ * @param string $name
262+ *
263+ * @return \Lucid\Console\Components\Feature
264+ */
265+ public function findFeature ($ name )
266+ {
267+ $ name = Str::feature ($ name );
268+ $ fileName = "$ name.php " ;
269+
270+ $ finder = new SymfonyFinder ();
271+ $ files = $ finder ->name ($ fileName )->in ($ this ->findServicesRootPath ())->files ();
272+ foreach ($ files as $ file ) {
273+ $ path = $ file ->getRealPath ();
274+ $ serviceName = strstr ($ file ->getRelativePath (), '/ ' , true );
275+ $ service = $ this ->findService ($ serviceName );
276+
277+ return new Feature (
278+ Str::realName ($ name , '/Feature/ ' ),
279+ $ fileName ,
280+ $ path ,
281+ $ this ->relativeFromReal ($ path ),
282+ $ service
283+ );
284+ }
285+ }
286+
236287 /**
237288 * Get the list of features,
238289 * optionally withing a specified service.
@@ -256,7 +307,6 @@ public function listFeatures($serviceName = '')
256307 }
257308 }
258309
259-
260310 $ features = [];
261311 foreach ($ services as $ service ) {
262312 $ serviceFeatures = new Collection ();
0 commit comments