execute method
Future<void>
execute(
)
override
Implementation
@override
Future<void> execute() async {
if (!repository.isInitialized) {
printToConsole(
message: "Repository is not initialized at path ${repository.repositoryPath}",
color: CliColor.red,
);
return;
}
StateData? stateData = repository.state.stateInfo;
if (stateData == null) {
printToConsole(
message: "Repository is doesn't have state data at ${repository.state.stateFilePath}",
color: CliColor.red,
);
return;
}
Branch branch = Branch(stateData.currentBranch, repository);
Map<BranchFileStatus, HashSet<String>> status = branch.getBranchStatus();
printToConsole(
message: "On branch ${branch.branchName}",
color: CliColor.defaultColor,
);
for (MapEntry<BranchFileStatus, HashSet<String>> e in status.entries) {
CliColor c = switch (e.key) {
BranchFileStatus.staged => CliColor.brightGreen,
BranchFileStatus.untracked => CliColor.white,
BranchFileStatus.unstaged => CliColor.red,
};
printToConsole(
message: "${e.key.name} files",
style: CliStyle.bold,
color: CliColor.defaultColor,
newLine: true,
);
printToConsole(
message: e.value.join("\n"),
color: c,
);
}
}