@@ -3,6 +3,7 @@ import 'dart:io';
3
3
import 'package:args/command_runner.dart' ;
4
4
import 'package:cli_spin/cli_spin.dart' ;
5
5
6
+ import '../../commons/entities/input_icons.dart' ;
6
7
import '../../commons/functions/get_input.dart' ;
7
8
import '../../commons/functions/load_project_configuration.dart' ;
8
9
import 'create_handler.dart' ;
@@ -44,15 +45,13 @@ class _CreateProjectCommand extends Command {
44
45
45
46
@override
46
47
void run () async {
47
- stdout.writeln ("✨ What would you like to name your new project? 🚀" );
48
- String ? projectName = stdin.readLineSync ();
49
- while (projectName == null || projectName == "" ) {
50
- stdout.writeln ("⚠ Please provide a name for your project to proceed:" );
51
- projectName = stdin.readLineSync ();
52
- }
53
- stdout.writeln ();
48
+ final projectName = getInput (
49
+ "What would you like to name your new project?" ,
50
+ onEmpty: "Please provide a name for your project to proceed!" ,
51
+ onValidated: (input) =>
52
+ input.replaceAll (RegExp (r'\s+' ), "_" ).toLowerCase (),
53
+ );
54
54
55
- projectName = projectName.replaceAll (RegExp (r'\s+' ), "_" ).toLowerCase ();
56
55
final fullstack = argResults? .flag ("flutter" ) != null ? true : false ;
57
56
58
57
final spinner = CliSpin (
@@ -68,7 +67,7 @@ class _CreateProjectCommand extends Command {
68
67
);
69
68
70
69
spinner.success (
71
- "$projectName project created 🚀 \n 💡To navigate to your project run \" cd $projectName \"\n 💡Then, use \" gazelle run\" to execute it!" ,
70
+ "$projectName project created ${ InputIcons . rocket } \n 💡To navigate to your project run \" cd $projectName \"\n 💡Then, use \" gazelle run\" to execute it!" ,
72
71
);
73
72
} on CreateProjectError catch (e) {
74
73
spinner.fail (e.message);
@@ -96,15 +95,12 @@ class _CreateRouteCommand extends Command {
96
95
CliSpin spinner = CliSpin ();
97
96
try {
98
97
await loadProjectConfiguration ();
99
- stdout.writeln ("✨ What would you like to name your new route? 🚀" );
100
- String ? routeName = stdin.readLineSync ();
101
- while (routeName == null || routeName == "" ) {
102
- stdout.writeln ("⚠ Please provide a name for your route to proceed:" );
103
- routeName = stdin.readLineSync ();
104
- }
105
- stdout.writeln ();
106
-
107
- routeName = routeName.replaceAll (RegExp (r'\s+' ), "_" ).toLowerCase ();
98
+ final routeName = getInput (
99
+ "What would you like to name your new route?" ,
100
+ onEmpty: "Please provide a name for your route to proceed!" ,
101
+ onValidated: (input) =>
102
+ input.replaceAll (RegExp (r'\s+' ), "_" ).toLowerCase (),
103
+ );
108
104
109
105
spinner = CliSpin (
110
106
text: "Creating $routeName route..." ,
@@ -120,7 +116,7 @@ class _CreateRouteCommand extends Command {
120
116
);
121
117
122
118
spinner.success (
123
- "$routeName route created 🚀 " ,
119
+ "$routeName route created ${ InputIcons . rocket } " ,
124
120
);
125
121
} on LoadProjectConfigurationGazelleNotFoundError catch (e) {
126
122
spinner.fail (e.errorMessage);
@@ -198,7 +194,7 @@ class _CreatHandlerCommand extends Command {
198
194
path: path,
199
195
);
200
196
201
- spinner.success ("$handlerName handler created 🚀 " );
197
+ spinner.success ("$handlerName handler created ${ InputIcons . rocket } " );
202
198
} on LoadProjectConfigurationGazelleNotFoundError catch (e) {
203
199
spinner.fail (e.errorMessage);
204
200
exit (e.errorCode);
0 commit comments