diff --git a/.idea/runConfigurations/Doctor.xml b/.idea/runConfigurations/Doctor.xml
new file mode 100644
index 00000000..bd640ddb
--- /dev/null
+++ b/.idea/runConfigurations/Doctor.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Service.xml b/.idea/runConfigurations/Service.xml
new file mode 100644
index 00000000..525203cb
--- /dev/null
+++ b/.idea/runConfigurations/Service.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/Show_Help.xml b/.idea/runConfigurations/Show_Help.xml
new file mode 100644
index 00000000..009fef31
--- /dev/null
+++ b/.idea/runConfigurations/Show_Help.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bin/angel.dart b/bin/angel.dart
index fe769e7f..3a095590 100644
--- a/bin/angel.dart
+++ b/bin/angel.dart
@@ -1,9 +1,22 @@
#!/usr/bin/env dart
-
library angel_cli.tool;
+import "dart:io";
+import "package:args/command_runner.dart";
import 'package:angel_cli/angel_cli.dart';
+final String DOCTOR = "doctor";
+
main(List args) {
- var parser = makeParser();
-}
\ No newline at end of file
+ var runner =
+ new CommandRunner("angel", "Command-line tools for the Angel framework.");
+
+ runner.addCommand(new DoctorCommand());
+ runner.addCommand(new ServiceCommand());
+
+ return runner.run(args).then((_) {}).catchError((exc, st) {
+ stderr.writeln("Oops, something went wrong: $exc");
+ stderr.writeln(st);
+ exitCode = 1;
+ });
+}
diff --git a/lib/angel_cli.dart b/lib/angel_cli.dart
index af96721c..4d3fa997 100644
--- a/lib/angel_cli.dart
+++ b/lib/angel_cli.dart
@@ -1,4 +1,3 @@
library angel_cli;
-import 'package:args/args.dart';
-part 'src/args.dart';
\ No newline at end of file
+export 'src/commands/commands.dart';
\ No newline at end of file
diff --git a/lib/src/args.dart b/lib/src/args.dart
deleted file mode 100644
index b8ac1483..00000000
--- a/lib/src/args.dart
+++ /dev/null
@@ -1,6 +0,0 @@
-part of angel_cli;
-
-ArgParser makeParser() {
- var result = new ArgParser(allowTrailingOptions: true);
- return result;
-}
\ No newline at end of file
diff --git a/lib/src/commands/commands.dart b/lib/src/commands/commands.dart
new file mode 100644
index 00000000..f3c15b74
--- /dev/null
+++ b/lib/src/commands/commands.dart
@@ -0,0 +1,4 @@
+library angel_cli.commands;
+
+export "doctor.dart";
+export "service.dart";
\ No newline at end of file
diff --git a/lib/src/commands/doctor.dart b/lib/src/commands/doctor.dart
new file mode 100644
index 00000000..836ab723
--- /dev/null
+++ b/lib/src/commands/doctor.dart
@@ -0,0 +1,38 @@
+import "dart:convert";
+import "dart:io";
+import "package:args/command_runner.dart";
+import "package:console/console.dart";
+
+class DoctorCommand extends Command {
+ final TextPen _pen = new TextPen();
+
+ @override
+ String get name => "doctor";
+
+ @override
+ String get description =>
+ "Ensures that the current system is capable of running Angel.";
+
+ @override
+ run() async {
+ print("Checking your system for dependencies...");
+ await _checkForGit();
+ }
+
+ _checkForGit() async {
+ try {
+ var git = await Process.start("git", ["--version"]);
+ if (await git.exitCode == 0) {
+ var version = await git.stdout.transform(UTF8.decoder).join();
+ _pen.green();
+ _pen("${Icon.CHECKMARK} Git executable found: v${version.replaceAll('git version', '').trim()}");
+ _pen();
+ } else
+ throw new Exception("Git executable exit code not 0");
+ } catch (exc) {
+ _pen.red();
+ _pen("${Icon.BALLOT_X} Git executable not found");
+ _pen();
+ }
+ }
+}
diff --git a/lib/src/commands/service.dart b/lib/src/commands/service.dart
new file mode 100644
index 00000000..c4d2196a
--- /dev/null
+++ b/lib/src/commands/service.dart
@@ -0,0 +1,51 @@
+import "package:args/command_runner.dart";
+import "package:console/console.dart";
+import "package:mustache4dart/mustache4dart.dart";
+
+class ServiceCommand extends Command {
+ final String CUSTOM = "Custom";
+ final String MEMORY = "In-Memory";
+ final String MONGO = "MongoDB";
+ final TextPen _pen = new TextPen();
+
+ @override String get name => "service";
+
+ @override String get description =>
+ "Creates a new service within the given project.";
+
+ @override
+ run() async {
+ var name = await readInput("Name of Service (not plural): ");
+ var chooser = new Chooser([MONGO, MEMORY, CUSTOM],
+ message: "What type of service would you like to create? ");
+ var type = await chooser.choose();
+ print("Creating $type service $name");
+
+ fail() {
+ _pen.red();
+ _pen("Could not successfully create service $name.");
+ _pen();
+ }
+
+ String serviceSource = "";
+
+ if (type == MONGO) {
+ serviceSource = _generateMongoService(name);
+ } else fail();
+
+ print("Generated source: ");
+ print(serviceSource);
+ }
+
+ _generateMongoService(String name) {
+ return '''
+ import "package:angel_mongo/angel_mongo.dart";
+
+ class ${name}Service extends MongoService {
+ ${name}Service(collection):super(collection) {
+ print("YEET");
+ }
+ }
+ ''';
+ }
+}
\ No newline at end of file
diff --git a/pubspec.yaml b/pubspec.yaml
index f1f1971a..5faddd53 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -6,8 +6,9 @@ homepage: https://github.com/angel-dart/angel_cli
executables:
angel: angel
dependencies:
+ analyzer: ">=0.28.1 <1.0.0"
args: ">=0.3.4 <1.0.0"
- colorize: ">=0.1.2 <1.0.0"
console: ">=2.2.3 <3.0.0"
+ dart_style: "0.2.9+1 <0.3.0"
mustache4dart: ">=1.0.0 <3.0.0"
yaml: ">=2.0.0 <3.0.0"
\ No newline at end of file