diff --git a/lib/commands/commands_list.dart b/lib/commands/commands_list.dart index a7cb9bb4..f245556f 100644 --- a/lib/commands/commands_list.dart +++ b/lib/commands/commands_list.dart @@ -29,6 +29,7 @@ final List commands = [ RemoveCommand(), SortCommand(), UpdateCommand(), + CleanCommand(), ]; class CommandParent extends Command { diff --git a/lib/commands/impl/clean/clean.dart b/lib/commands/impl/clean/clean.dart new file mode 100644 index 00000000..897d5f5d --- /dev/null +++ b/lib/commands/impl/clean/clean.dart @@ -0,0 +1,29 @@ +import '../../../common/utils/shell/shel.utils.dart'; +import '../../../core/internationalization.dart'; +import '../../../core/locales.g.dart'; +import '../../interface/command.dart'; + +class CleanCommand extends Command { + @override + String get commandName => 'clean'; + + @override + Future execute() async { + await ShellUtils.flutterClean(); + } + + @override + String? get hint => Translation(LocaleKeys.hint_clean).tr; + + @override + String get codeSample => 'get clean'; + + @override + int get maxParameters => 0; + + @override + bool validate() { + super.validate(); + return true; + } +} diff --git a/lib/commands/impl/commads_export.dart b/lib/commands/impl/commads_export.dart index c43c1aed..b22845dc 100644 --- a/lib/commands/impl/commads_export.dart +++ b/lib/commands/impl/commads_export.dart @@ -13,3 +13,4 @@ export 'remove/remove.dart'; export 'sort/sort.dart'; export 'update/update.dart'; export 'version/version.dart'; +export 'clean/clean.dart'; \ No newline at end of file diff --git a/lib/common/utils/shell/shel.utils.dart b/lib/common/utils/shell/shel.utils.dart index c7aba13e..0fa12b96 100644 --- a/lib/common/utils/shell/shel.utils.dart +++ b/lib/common/utils/shell/shel.utils.dart @@ -15,6 +15,11 @@ class ShellUtils { await run('dart pub get', verbose: true); } + static Future flutterClean() async { + LogService.info('Running `flutter clean` …'); + await run('flutter clean', verbose: true); + } + static Future addPackage(String package) async { LogService.info('Adding package $package …'); await run('dart pub add $package', verbose: true); @@ -33,11 +38,9 @@ class ShellUtils { ) async { LogService.info('Running `flutter create $path` …'); - // Note: -i and -a flags are only supported for --template=plugin - // For regular Flutter projects, Flutter uses Swift/Kotlin by default - await run( - 'flutter create --no-pub --org $org "$path"', - verbose: true); + // Note: -i and -a flags are only supported for --template=plugin + // For regular Flutter projects, Flutter uses Swift/Kotlin by default + await run('flutter create --no-pub --org $org "$path"', verbose: true); } static Future update( diff --git a/lib/core/locales.g.dart b/lib/core/locales.g.dart index 0fcd5858..4e55be9a 100644 --- a/lib/core/locales.g.dart +++ b/lib/core/locales.g.dart @@ -4,7 +4,6 @@ // ignore_for_file: constant_identifier_names // ignore: avoid_classes_with_only_static_members - class AppTranslation { static Map> translations = { 'tr_TR': Locales.tr_TR, @@ -45,6 +44,7 @@ class LocaleKeys { static const error_access_denied = 'error_access_denied'; static const error_unexpected = 'error_unexpected'; static const example = 'example'; + static const hint_clean = 'hint_clean'; static const hint_create_controller = 'hint_create_controller'; static const hint_create_page = 'hint_create_page'; static const hint_create_project = 'hint_create_project'; @@ -352,7 +352,8 @@ class Locales { 'error_failed_to_connect': 'Failed to connect with %s.', 'error_no_valid_file_or_url': '%s is not a file or valid url.', 'error_unnecessary_parameter': 'the %s parameter is not necessary.', - 'error_unnecessary_parameter_plural': 'the %s parameters are not necessary.', + 'error_unnecessary_parameter_plural': + 'the %s parameters are not necessary.', 'error_nonexistent_directory': '%s directory does not exist.', 'error_empty_directory': '%s is empty.', 'error_invalid_json': '%s is not a valid json file.', diff --git a/translations/en.json b/translations/en.json index 5ad83168..c68bf81c 100644 --- a/translations/en.json +++ b/translations/en.json @@ -36,6 +36,7 @@ "example": "Example:", "warning": "Warning:", "hint": { + "clean": "Runs flutter clean", "create": { "controller": "Generate controller", "page": "Use to generate pages",