From b8e6813f49146988f3d3640dc017a058fee07165 Mon Sep 17 00:00:00 2001 From: Pebkac03 Date: Sat, 4 Jan 2025 03:07:36 +0100 Subject: [PATCH] feat: prompt user if app name is not snake case --- .../commands/create/create_app_command.dart | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/src/commands/create/create_app_command.dart b/lib/src/commands/create/create_app_command.dart index 17f500f..8c46ba4 100644 --- a/lib/src/commands/create/create_app_command.dart +++ b/lib/src/commands/create/create_app_command.dart @@ -81,13 +81,25 @@ class CreateAppCommand extends Command { configFilePath: argResults![ksConfigPath], ); + final templateType = argResults![ksTemplateType]; + + // appName validation and recasing final List workingDirectoryList = argResults!.rest.first.split('/'); - workingDirectoryList - .add(ReCase(workingDirectoryList.removeLast()).snakeCase); - final String appName = workingDirectoryList.last; - final String workingDirectory = workingDirectoryList.join('/'); - final templateType = argResults![ksTemplateType]; + final String originalAppName = workingDirectoryList.removeLast(); + final String appName = ReCase(originalAppName).snakeCase; + if (originalAppName != appName) { + _log.info( + message: + '$originalAppName is not snake_case as required by dart, did you mean $appName? [Y/N]'); + String input; + do { + input = stdin.readLineSync()?.toUpperCase().trim() ?? ''; + } while (!(input == 'Y' || input == 'N')); + input == 'N' ? throw 'error: project name not snake_case' : {}; + } + workingDirectoryList.add(appName); + final workingDirectory = workingDirectoryList.join('/'); _processService.formattingLineLength = argResults![ksLineLength]; await _processService.runCreateApp(