Skip to content

Commit

Permalink
fix: improve generate command (#47)
Browse files Browse the repository at this point in the history
Format code after generated files are created. Added -l option to
override the line length for formatting code.
  • Loading branch information
ferrarafer authored Jul 2, 2024
1 parent 66386c4 commit 327fe8d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/src/commands/generate/generate_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<PosthogService>();
final _configService = locator<ConfigService>();
final _log = locator<ColorizedLogService>();
final _processService = locator<ProcessService>();

Expand All @@ -23,6 +25,12 @@ class GenerateCommand extends Command {

GenerateCommand() {
argParser
..addOption(
ksLineLength,
abbr: 'l',
help: kCommandHelpLineLength,
valueHelp: '80',
)
..addFlag(
ksDeleteConflictOutputs,
abbr: 'd',
Expand All @@ -41,10 +49,13 @@ class GenerateCommand extends Command {
@override
Future<void> 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,
);
Expand Down

0 comments on commit 327fe8d

Please sign in to comment.