run method

  1. @override
void run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
void run() {
  if (!ContextService.isInitialized()) {
    print('ContextForge has not been initialized in this repository.\n');
    print('Run:');
    print('  contextforge init');
    return;
  }

  ContextService.ensureContextFilesExist();
  ContextService.ensureDataFilesExist();

  final focus = argResults?['focus'] as String?;

  if (focus != null) {
    _printFocusedByArea(focus);
  } else {
    final activeContext = ContextService.getActiveContext();
    final decisions = ContextService.loadDecisions();
    if (activeContext.hasActiveContext()) {
      _printFocusedPrompt(activeContext, decisions);
    } else {
      _printStandardPrompt();
    }
  }

  print('✔ Context-aware prompt generated');
}