Lookin good

This commit is contained in:
thosakwe 2016-09-14 00:33:28 -04:00
parent 166974ff97
commit 63d8359fab
10 changed files with 133 additions and 12 deletions

View file

@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Doctor" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
<option name="arguments" value="doctor" />
<option name="filePath" value="$PROJECT_DIR$/bin/angel.dart" />
<method />
</configuration>
</component>

View file

@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Service" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
<option name="arguments" value="service" />
<option name="filePath" value="$PROJECT_DIR$/bin/angel.dart" />
<method />
</configuration>
</component>

View file

@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Show Help" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
<option name="arguments" value="--help" />
<option name="filePath" value="$PROJECT_DIR$/bin/angel.dart" />
<method />
</configuration>
</component>

View file

@ -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<String> args) {
var parser = makeParser();
}
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;
});
}

View file

@ -1,4 +1,3 @@
library angel_cli;
import 'package:args/args.dart';
part 'src/args.dart';
export 'src/commands/commands.dart';

View file

@ -1,6 +0,0 @@
part of angel_cli;
ArgParser makeParser() {
var result = new ArgParser(allowTrailingOptions: true);
return result;
}

View file

@ -0,0 +1,4 @@
library angel_cli.commands;
export "doctor.dart";
export "service.dart";

View file

@ -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();
}
}
}

View file

@ -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");
}
}
''';
}
}

View file

@ -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"