Skip to content

Commit

Permalink
feat: prompt user if app name is not snake case
Browse files Browse the repository at this point in the history
  • Loading branch information
Pebkac03 committed Jan 4, 2025
1 parent 56a2e09 commit b8e6813
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lib/src/commands/create/create_app_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,25 @@ class CreateAppCommand extends Command {
configFilePath: argResults![ksConfigPath],
);

final templateType = argResults![ksTemplateType];

// appName validation and recasing
final List<String> 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(
Expand Down

0 comments on commit b8e6813

Please sign in to comment.