Skip to content

Commit

Permalink
Implented remove in pubm
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilishwarkulal committed Nov 3, 2023
1 parent 4de1279 commit a247893
Show file tree
Hide file tree
Showing 3 changed files with 310 additions and 61 deletions.
5 changes: 2 additions & 3 deletions lib/pubm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ class Pubm with PubspecManager {

/// Register [Logger] and [Configuration] as singleton services
void _setupSingletonServices(List<String> args) {
GetIt.I.registerSingleton<Logger>(args.contains('-v')
? Logger.verbose()
: Logger.standard(ansi: Ansi(true)));
GetIt.I.registerSingleton<Logger>(
args.contains('-v') ? Logger.verbose() : Logger.standard(ansi: Ansi(true)));

GetIt.I.registerSingleton<Configuration>(Configuration(args));
}
14 changes: 5 additions & 9 deletions lib/src/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class Configuration {
dynamic pubspec = await _getPubspec();
dynamic yaml = pubspec['pubm_config'] ?? YamlMap();

final String? buildArgsConfig =
(_args['build-args'] ?? yaml['build_args'])?.toString();
final String? buildArgsConfig = (_args['build-args'] ?? yaml['build_args'])?.toString();
if (buildArgsConfig != null && buildArgsConfig.isNotEmpty) {
CommandLineConverter commandLineConverter = CommandLineConverter();
buildArgs = commandLineConverter.convert(buildArgsConfig);
Expand All @@ -41,15 +40,13 @@ class Configuration {

if (_args['help']) {
_logger.stdout('Usage: pubm -f <flavor>');
_logger.stdout(
'Usage: pubm -f <flavor> -v (verbose) to enable verbose mode');
_logger.stdout(
'Usage: pubm -h to get the list of available commands and how to use');
_logger.stdout('Usage: pubm -f <flavor> -v (verbose) to enable verbose mode');
_logger.stdout('Usage: pubm -h to get the list of available commands and how to use');

return false;
}

flavor = _args['flavor']?.toString() ?? '';
flavor = _args['flavor']?.toString() ?? 'test';
if (flavor.isEmpty) {
exitCode = 2;
_logger.stderr('Usage: dart manage.dart -f <flavor>'.red);
Expand All @@ -72,8 +69,7 @@ class Configuration {
_logger.trace('parsing cli arguments');

ArgParser parser = ArgParser()
..addOption('flavor',
abbr: 'f', help: 'flavor of YAML file (pubspec_/flavor/.yaml)')
..addOption('flavor', abbr: 'f', help: 'flavor of YAML file (pubspec_/flavor/.yaml)')
..addOption('build-args')
..addFlag('help', negatable: false, abbr: 'h');

Expand Down
Loading

0 comments on commit a247893

Please sign in to comment.