mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
71 lines
2.0 KiB
Dart
71 lines
2.0 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// @dart = 2.8
|
|
|
|
import 'dart:convert' show jsonDecode;
|
|
|
|
import 'package:args/command_runner.dart';
|
|
import 'package:file/file.dart';
|
|
import 'package:meta/meta.dart';
|
|
import 'package:platform/platform.dart';
|
|
|
|
import './proto/conductor_state.pb.dart' as pb;
|
|
import './repository.dart';
|
|
import './state.dart';
|
|
import './stdio.dart';
|
|
|
|
const String kVerboseFlag = 'verbose';
|
|
const String kStateOption = 'state-file';
|
|
|
|
/// Command to print the status of the current Flutter release.
|
|
class StatusCommand extends Command<void> {
|
|
StatusCommand({
|
|
@required this.checkouts,
|
|
}) : platform = checkouts.platform,
|
|
fileSystem = checkouts.fileSystem,
|
|
stdio = checkouts.stdio {
|
|
final String defaultPath = defaultStateFilePath(platform);
|
|
argParser.addOption(
|
|
kStateOption,
|
|
defaultsTo: defaultPath,
|
|
help: 'Path to persistent state file. Defaults to $defaultPath',
|
|
);
|
|
argParser.addFlag(
|
|
kVerboseFlag,
|
|
abbr: 'v',
|
|
defaultsTo: false,
|
|
help: 'Also print logs.',
|
|
);
|
|
}
|
|
|
|
final Checkouts checkouts;
|
|
final FileSystem fileSystem;
|
|
final Platform platform;
|
|
final Stdio stdio;
|
|
|
|
@override
|
|
String get name => 'status';
|
|
|
|
@override
|
|
String get description => 'Print status of current release.';
|
|
|
|
@override
|
|
void run() {
|
|
final File stateFile = checkouts.fileSystem.file(argResults[kStateOption]);
|
|
if (!stateFile.existsSync()) {
|
|
stdio.printStatus(
|
|
'No persistent state file found at ${argResults[kStateOption]}.');
|
|
return;
|
|
}
|
|
final pb.ConductorState state = pb.ConductorState();
|
|
state.mergeFromProto3Json(jsonDecode(stateFile.readAsStringSync()));
|
|
stdio.printStatus(presentState(state));
|
|
if (argResults[kVerboseFlag] as bool) {
|
|
stdio.printStatus('\nLogs:');
|
|
state.logs.forEach(stdio.printStatus);
|
|
}
|
|
}
|
|
}
|