@@ -117,7 +117,7 @@ namespace cucumber_cpp::library
117117 runCommand->add_option (" --outputfolder" , options.outputfolder , " Specifies the output folder for generated report files" )->group (" report generation" );
118118 runCommand->add_option (" --reportfile" , options.reportfile , " Specifies the output name for generated report files" )->group (" report generation" );
119119 runCommand->add_flag (" --dry" , options.dryrun , " Generate report without running tests" );
120- runCommand->add_flag (" --unused" , options.printStepsNotUsed , " Show step definitions that were not used" )-> default_val ( false ) ;
120+ runCommand->add_flag (" --unused" , options.printStepsNotUsed , " Show step definitions that were not used" );
121121
122122 reporters.Add (" console" , std::make_unique<report::StdOutReport>());
123123 reporters.Add (" junit-xml" , std::make_unique<report::JunitReport>(options.outputfolder , options.reportfile ));
@@ -217,26 +217,31 @@ namespace cucumber_cpp::library
217217 testRunner.Run (GetFeatureTree (featureTreeFactory, tagExpression));
218218
219219 if (options.printStepsNotUsed )
220- {
221- auto isUsed = [](const StepRegistry::EntryView& entry)
222- {
223- return entry.used > 0 ;
224- };
225- auto unusedSteps = stepRegistry.List () | std::views::filter (std::not_fn (isUsed));
226- if (std::ranges::begin (unusedSteps) == std::ranges::end (unusedSteps))
227- std::cout << " \n All steps have been used." ;
228- else
229- {
230- std::cout << " \n The following steps have not been used:" ;
231- for (const auto & entry : unusedSteps)
232- std::cout << " \n - " << std::visit (cucumber_expression::PatternVisitor{}, entry.stepRegex );
233- }
234- }
220+ PrintStepsNotUsed (stepRegistry);
235221
236222 std::cout << ' \n '
237223 << std::flush;
238224 }
239225
226+ void Application::PrintStepsNotUsed (StepRegistry& stepRegistry)
227+ {
228+ auto isUnused = [](const StepRegistry::EntryView& entry)
229+ {
230+ return entry.used == 0 ;
231+ };
232+
233+ auto unusedSteps = stepRegistry.List () | std::views::filter (isUnused);
234+
235+ if (std::ranges::empty (unusedSteps))
236+ std::cout << " \n All steps have been used." ;
237+ else
238+ {
239+ std::cout << " \n The following steps have not been used:" ;
240+ for (const auto & entry : unusedSteps)
241+ std::cout << " \n - " << std::visit (cucumber_expression::SourceVisitor{}, entry.stepRegex );
242+ }
243+ }
244+
240245 std::vector<std::unique_ptr<engine::FeatureInfo>> Application::GetFeatureTree (const engine::FeatureTreeFactory& featureTreeFactory, std::string_view tagExpression)
241246 {
242247
0 commit comments