blob: e5fe849119fb6b8cf3f65e56e0f73a8793429972 [file] [log] [blame]
// Copyright 2023 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:args/args.dart';
import 'package:args/command_runner.dart';
extension CommandExtension on Command {
void logStatus(String log) {
print('[$name] $log');
}
}
extension BuildCommandArgsExtension on ArgParser {
void addBulidModeOption() {
addOption(
BuildCommandArgs.buildMode.flagName,
allowed: ['debug', 'profile', 'release'],
defaultsTo: 'release',
help: 'The build mode to use for the DevTools web app. This should only'
' be "debug" or "profile" for the purpose of local development.',
);
}
void addPubGetFlag() {
addFlag(
BuildCommandArgs.pubGet.flagName,
negatable: true,
defaultsTo: true,
help: 'Whether to run `devtools_tool pub-get --only-main` before building'
' the DevTools web app.',
);
}
void addUpdatePerfettoFlag() {
addFlag(
BuildCommandArgs.updatePerfetto.flagName,
negatable: false,
defaultsTo: false,
help: 'Whether to update the Perfetto assets before building DevTools.',
);
}
void addUpdateFlutterFlag() {
addFlag(
BuildCommandArgs.updateFlutter.flagName,
negatable: true,
defaultsTo: true,
help: 'Whether to update the Flutter SDK contained in the '
'"tool/flutter-sdk" directory.',
);
}
}
enum BuildCommandArgs {
buildMode('build-mode'),
pubGet('pub-get'),
updateFlutter('update-flutter'),
updatePerfetto('update-perfetto');
const BuildCommandArgs(this.flagName);
final String flagName;
String asArg({bool negated = false}) =>
valueAsArg(flagName, negated: negated);
}
String valueAsArg(String value, {bool negated = false}) =>
'--${negated ? 'no-' : ''}$value';