run method

Future<void> run(
  1. List<String> args
)

Runs the CLI with the given arguments.

Detects if the current directory is a Flutter project and routes to the feature manager, or starts the project creation flow.

Implementation

Future<void> run(List<String> args) async {
  final currentDir = Directory.current.path;

  // If already in a Flutter project, skip creation and go to feature manager
  if (FsUtils.isFlutterProjectRoot(currentDir)) {
    Console.printBanner();
    Console.success('Flutter project detected at: ${p.basename(currentDir)}');
    Console.separator();

    final sm = _detectStateManagement(currentDir);
    Console.info('State management: ${sm.label}');

    await FeatureManagerCommand(
      projectPath: currentDir,
      stateManagement: sm,
    ).run();
    return;
  }

  // New project flow
  final createCommand = CreateProjectCommand();
  final config = await createCommand.run(currentDir);

  if (config == null) {
    Console.error('Project creation cancelled.');
    exit(1);
  }

  final projectDir = FsUtils.isFlutterProjectRoot(currentDir)
      ? currentDir
      : p.join(currentDir, config.name);

  // After creation, launch feature manager
  await FeatureManagerCommand(
    projectPath: projectDir,
    stateManagement: config.stateManagement,
  ).run();
}