mirror of
https://github.com/danog/dart-sass.git
synced 2024-11-30 04:39:03 +01:00
Implement --version flag for cli (#53)
Co-authored-by: Natalie Weizenbaum <nweiz@google.com>
This commit is contained in:
parent
4396693276
commit
d2063513af
@ -5,6 +5,9 @@
|
||||
* Emit colors as `Value.HslColor` if that internal representation is
|
||||
available.
|
||||
|
||||
* Add a `--version` flag that will print a `VersionResponse` as JSON, for ease
|
||||
of human identification.
|
||||
|
||||
## 1.0.0-beta.10
|
||||
|
||||
* Support version 1.0.0-beta.12 of the Sass embedded protocol:
|
||||
|
@ -8,6 +8,11 @@ and importers.
|
||||
[Dart Sass]: https://sass-lang.com/dart-sass
|
||||
[Embedded Sass protocol]: https://github.com/sass/sass-embedded-protocol/blob/master/README.md#readme
|
||||
|
||||
### Usage
|
||||
|
||||
- `dart_sass_embedded` starts the compiler and listens on stdin.
|
||||
- `dart_sass_embedded --version` prints `versionResponse` with `id = 0` in JSON and exits.
|
||||
|
||||
### Releases
|
||||
|
||||
Binary releases are available from the [GitHub release page]. We recommend that
|
||||
|
@ -19,6 +19,14 @@ import 'package:sass_embedded/src/utils.dart';
|
||||
|
||||
void main(List<String> args) {
|
||||
if (args.isNotEmpty) {
|
||||
if (args.first == "--version") {
|
||||
var response = Dispatcher.versionResponse();
|
||||
response.id = 0;
|
||||
stdout.writeln(
|
||||
JsonEncoder.withIndent(" ").convert(response.toProto3Json()));
|
||||
return;
|
||||
}
|
||||
|
||||
stderr.writeln(
|
||||
"This executable is not intended to be executed with arguments.\n"
|
||||
"See https://github.com/sass/embedded-protocol#readme for details.");
|
||||
|
@ -57,16 +57,10 @@ class Dispatcher {
|
||||
|
||||
switch (message.whichMessage()) {
|
||||
case InboundMessage_Message.versionRequest:
|
||||
_send(OutboundMessage()
|
||||
..versionResponse = (OutboundMessage_VersionResponse()
|
||||
..protocolVersion =
|
||||
const String.fromEnvironment("protocol-version")
|
||||
..compilerVersion =
|
||||
const String.fromEnvironment("compiler-version")
|
||||
..implementationVersion =
|
||||
const String.fromEnvironment("implementation-version")
|
||||
..implementationName = "Dart Sass"
|
||||
..id = message.versionRequest.id));
|
||||
var request = message.versionRequest;
|
||||
var response = versionResponse();
|
||||
response.id = request.id;
|
||||
_send(OutboundMessage()..versionResponse = response);
|
||||
break;
|
||||
|
||||
case InboundMessage_Message.compileRequest:
|
||||
@ -226,4 +220,14 @@ class Dispatcher {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a [OutboundMessage_VersionResponse]
|
||||
static OutboundMessage_VersionResponse versionResponse() {
|
||||
return OutboundMessage_VersionResponse()
|
||||
..protocolVersion = const String.fromEnvironment("protocol-version")
|
||||
..compilerVersion = const String.fromEnvironment("compiler-version")
|
||||
..implementationVersion =
|
||||
const String.fromEnvironment("implementation-version")
|
||||
..implementationName = "Dart Sass";
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: sass_embedded
|
||||
version: 1.0.0-dev
|
||||
version: 1.0.0-beta.11
|
||||
description: An implementation of the Sass embedded protocol using Dart Sass.
|
||||
author: Sass Team
|
||||
homepage: https://github.com/sass/dart-sass-embedded
|
||||
|
Loading…
Reference in New Issue
Block a user