Skip to content

Commit

Permalink
Added Pattern commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
DrRetro2033 committed Aug 26, 2024
1 parent 5024fa1 commit 31de399
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var arceus = Arceus();
Future<dynamic> main(List<String> arguments) async {
var runner = CommandRunner('arceus', "The ultimate save manager.");
runner.addCommand(ConstellationCommands());
runner.addCommand(PatternCommands());
if (arguments.isNotEmpty) {
return await runner.run(arguments);
}
Expand Down Expand Up @@ -66,3 +67,33 @@ class ShowMapConstellationCommand extends Command {
Constellation(argResults?["path"]).showMap();
}
}

class PatternCommands extends Command {
@override
String get name => "pattern";
@override
String get description => "Commands for patterns.";

PatternCommands() {
addSubcommand(ReadPatternCommand());
}
}

class ReadPatternCommand extends Command {
@override
String get description => "Read a file using a pattern.";

@override
String get name => "read";

ReadPatternCommand() {
argParser.addOption("pattern",
abbr: "p", defaultsTo: Directory.current.path);
argParser.addOption("file", abbr: "f", defaultsTo: Directory.current.path);
}

@override
void run() {
FilePattern(argResults?["pattern"]).read(File(argResults?["file"]));
}
}

0 comments on commit 31de399

Please sign in to comment.