Skip to content

add steps and path #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/src/cli/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import 'package:flutter_starter_cli/src/cli/cli.dart';
import 'package:flutter_starter_cli/src/utils.dart';

class Actions {
static Future<void> _addStep(message) async {
Status.start('Adding $message...');
await Future.delayed(const Duration(seconds: 1));
Status.complete('$message Added!!!');
}

static Future<void> createProject(String path, String state) async {
Status.start('Project Creating...');
try {
Expand Down Expand Up @@ -47,6 +53,12 @@ class Actions {
} catch (_) {}
}),
);
await _addStep('State Management');
await _addStep('API Service');
await _addStep('Localization');
await _addStep('Routes');
await _addStep('Themes');
if (test) await _addStep('Test Cases');
}

static Future<void> setupPackages(String path, String api, bool test) async {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/cli/cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Cli {
return result;
}

static _delete(Directory target) async {
await target.delete(recursive: true);
static _delete(Directory target) {
target.deleteSync(recursive: true);
}

static Future<void> cloneProject(String path, String state) async {
Expand Down
21 changes: 18 additions & 3 deletions lib/src/commands/create_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';

import 'package:args/command_runner.dart';
import 'package:mason_logger/mason_logger.dart';
import 'package:path/path.dart';

import 'package:flutter_starter_cli/src/cli/actions.dart';
import 'package:flutter_starter_cli/src/command_runner.dart';
Expand All @@ -22,6 +23,11 @@ class CreateCommand extends Command<int> {
help: 'The organization for the project.',
defaultsTo: 'com.example',
)
..addOption(
'path',
abbr: 'p',
help: 'The directory path for the project.',
)
..addOption(
'state',
abbr: 's',
Expand Down Expand Up @@ -68,12 +74,17 @@ class CreateCommand extends Command<int> {
final api = _api;
final test = state == StateManagement.bloc.name ? _test : true;
final git = _git;
final path = '${Directory.current.path}/$name';
final dir = _dir(name);
final path = join(Directory.current.path, dir);
final target = Directory(path);
if (!target.existsSync()) await target.create();
if (!target.existsSync()) target.createSync(recursive: true);
await onGenerateComplete(
_logger, path, name, desc, org, state, api, test, git);
_logger.success('Your Project is Ready to Use 🚀');
_logger.success('''Your Project is Ready to Use 🚀
Type:-
\$ cd $dir
\$ flutter run
In order to run your application.''');
return ExitCode.success.code;
}

Expand Down Expand Up @@ -138,6 +149,10 @@ class CreateCommand extends Command<int> {
);
}

String _dir(name) {
return argResults?['path'] ?? name;
}

Future<void> onGenerateComplete(
Logger logger,
String path,
Expand Down