From 327fe8df8702efe07159e41a2db4d03383efc91b Mon Sep 17 00:00:00 2001 From: Fernando Ferrara Date: Tue, 2 Jul 2024 01:02:46 -0300 Subject: [PATCH] fix: improve generate command (#47) Format code after generated files are created. Added -l option to override the line length for formatting code. --- lib/src/commands/generate/generate_command.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/commands/generate/generate_command.dart b/lib/src/commands/generate/generate_command.dart index 0282198..66786e3 100644 --- a/lib/src/commands/generate/generate_command.dart +++ b/lib/src/commands/generate/generate_command.dart @@ -5,12 +5,14 @@ import 'package:stacked_cli/src/constants/command_constants.dart'; import 'package:stacked_cli/src/constants/message_constants.dart'; import 'package:stacked_cli/src/locator.dart'; import 'package:stacked_cli/src/services/colorized_log_service.dart'; +import 'package:stacked_cli/src/services/config_service.dart'; import 'package:stacked_cli/src/services/posthog_service.dart'; import 'package:stacked_cli/src/services/process_service.dart'; import 'package:stacked_cli/src/templates/template_constants.dart'; class GenerateCommand extends Command { final _analyticsService = locator(); + final _configService = locator(); final _log = locator(); final _processService = locator(); @@ -23,6 +25,12 @@ class GenerateCommand extends Command { GenerateCommand() { argParser + ..addOption( + ksLineLength, + abbr: 'l', + help: kCommandHelpLineLength, + valueHelp: '80', + ) ..addFlag( ksDeleteConflictOutputs, abbr: 'd', @@ -41,10 +49,13 @@ class GenerateCommand extends Command { @override Future run() async { try { + await _configService.composeAndLoadConfigFile(); + _processService.formattingLineLength = argResults![ksLineLength]; await _processService.runBuildRunner( shouldDeleteConflictingOutputs: argResults?[ksDeleteConflictOutputs], shouldWatch: argResults?[ksWatch], ); + await _processService.runFormat(); await _analyticsService.generateCodeEvent( arguments: argResults!.arguments, );