Skip to content

Commit

Permalink
Better env var logging on doctor command
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Oct 4, 2023
1 parent 28c578c commit b601c7b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
47 changes: 30 additions & 17 deletions lib/src/commands/doctor_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ class DoctorCommand extends BaseCommand {
void printFVMDetails(FVMContext context) {}
void _printProject(Project project) {
logger.info('Project:');
final table = createTable()
..insertColumn(header: 'Project', alignment: TextAlignment.left)
..insertColumn(header: project.name, alignment: TextAlignment.left);
final table = createTable(['Project', project.name]);

table.insertRows([
['Directory', project.path],
Expand Down Expand Up @@ -85,9 +83,7 @@ class DoctorCommand extends BaseCommand {
logger
..spacer
..info('IDEs:');
final table = createTable()
..insertColumn(header: 'IDEs', alignment: TextAlignment.left)
..insertColumn(header: '', alignment: TextAlignment.left);
final table = createTable(['IDEs', 'Value']);

table.insertRow([kVsCode]);
// Check for .vscode directory
Expand Down Expand Up @@ -152,22 +148,39 @@ class DoctorCommand extends BaseCommand {
logger.write(table.toString());
}

void _printEnvironmentDetails(String? flutterWhich, String? dartWhich) {
void _printEnvironmentDetails(
String? flutterWhich,
String? dartWhich,
) {
logger
..spacer
..info('Environment:');
final table = createTable()
..insertColumn(
header: 'Environment Detail', alignment: TextAlignment.left)
..insertColumn(header: 'Path/Value', alignment: TextAlignment.left);

var table = createTable(
['Environment Variables', 'Value'],
);

table.insertRows([
['Flutter PATH', flutterWhich ?? 'Not found'],
['Dart PATH', dartWhich ?? 'Not found'],
]);

for (var key in ConfigKeys.values) {
table.insertRow([key.envKey, ctx.environment[key.envKey] ?? 'N/A']);
}

table.insertRows([
['Flutter PATH', flutterWhich ?? 'Not found'],
['Dart PATH', dartWhich ?? 'Not found'],
]);

logger.write(table.toString());

table = createTable(
['Platform', 'Value'],
);

table.insertRows([
['Flutter Path', flutterWhich ?? 'Not found'],
['Dart Path', dartWhich ?? 'Not found'],
[
ConfigKeys.cachePath.envKey,
ctx.environment[ConfigKeys.cachePath.envKey] ?? 'Not set'
],
['OS', '${Platform.operatingSystem} ${Platform.operatingSystemVersion}'],
['Dart Locale', Platform.localeName],
['Dart runtime', Platform.version],
Expand Down
12 changes: 10 additions & 2 deletions lib/src/utils/console_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ import 'package:fvm/src/models/cache_flutter_version_model.dart';
import '../../exceptions.dart';
import '../services/logger_service.dart';

Table createTable() {
return Table()
Table createTable([List<String> columns = const []]) {
final table = Table()
..borderColor = ConsoleColor.white
..borderType = BorderType.grid
..borderStyle = BorderStyle.square
..headerStyle = FontStyle.bold;

for (final column in columns) {
table.insertColumn(
header: column,
alignment: TextAlignment.left,
);
}
return table;
}

/// Allows to select from cached sdks.
Expand Down

0 comments on commit b601c7b

Please sign in to comment.