diff --git a/puro/lib/src/cli.dart b/puro/lib/src/cli.dart index f0c17eb..3077e1e 100644 --- a/puro/lib/src/cli.dart +++ b/puro/lib/src/cli.dart @@ -19,6 +19,7 @@ import 'commands/flutter.dart'; import 'commands/gc.dart'; import 'commands/internal_generate_ast_parser.dart'; import 'commands/internal_generate_docs.dart'; +import 'commands/locate_sdk.dart'; import 'commands/ls_versions.dart'; import 'commands/prefs.dart'; import 'commands/pub.dart'; @@ -263,6 +264,7 @@ void main(List args) async { ..addCommand(DartCommand()) ..addCommand(PubCommand()) ..addCommand(RunCommand()) + ..addCommand(LocateSdkCommand()) ..addCommand(GenerateDocsCommand()) ..addCommand(GenerateASTParserCommand()) ..addCommand(PuroUpgradeCommand()) diff --git a/puro/lib/src/commands/locate_sdk.dart b/puro/lib/src/commands/locate_sdk.dart new file mode 100644 index 0000000..ddcf184 --- /dev/null +++ b/puro/lib/src/commands/locate_sdk.dart @@ -0,0 +1,34 @@ +import 'dart:async'; + +import '../command.dart'; +import '../command_result.dart'; +import '../env/default.dart'; +import '../terminal.dart'; + +class LocateSdkCommand extends PuroCommand { + @override + final name = 'sdk'; + + @override + // Command will be used by tools, + // so there's no way to react anyways + final allowUpdateCheck = false; + + @override + final description = '''Prints the SDK path of the current environment. + +This can be used to configure vscode://settings/dart.getFlutterSdkCommand +to automatically pick up the SDK of your puro environment. + +See https://github.com/Dart-Code/Dart-Code/pull/5377'''; + + @override + Future? run() async { + final environment = await getProjectEnvOrDefault(scope: scope); + final path = environment.flutter.sdkDir.absolute.path; + return BasicMessageResult( + path, + type: CompletionType.plain, + ); + } +}