handleOpenTarget function

Future<void> handleOpenTarget(
  1. String target
)

Implementation

Future<void> handleOpenTarget(String target) async {
  final SetupConfig? config = await ProjectConfigLoader.load();
  if (config == null) {
    ProjectConfigLoader.printMissingConfigHelp();
    return;
  }

  final String? destination = _resolveOpenTarget(config, target);
  if (destination == null) {
    _printOpenHelp(config);
    return;
  }

  if (target == 'guide' && !File(destination).existsSync()) {
    await SetupGuidance.writeProjectGuide(config);
  }
  if (target == 'docs' && !Directory(destination).existsSync()) {
    await DocsGenerator.write(config);
  }

  if (await LinkOpener.open(destination)) {
    success('Opened: $destination');
  } else {
    error('Could not open: $destination');
  }
}