Информативный вывод при вызове status

This commit is contained in:
Alexander Zhirov 2025-05-28 00:20:27 +03:00
parent aa4260cdb9
commit c388d01a2f
Signed by: alexander
GPG key ID: C8D8BE544A27C511

View file

@ -44,6 +44,22 @@ class Snag {
return result;
}
private string gitStatus(string shortStatus, bool formatted = false) {
immutable string[string] statusMap = [
"??": "Untracked",
"A": "Added",
"M": "Modified",
"D": "Deleted",
"R": "Renamed",
"C": "Copied",
"U": "Unmerged",
"T": "Type changed",
"!": "Ignored"
];
string fullStatus = statusMap.get(shortStatus, shortStatus);
return formatted && fullStatus.length < 8 ? fullStatus ~ "\t" : fullStatus;
}
void initialize(bool force) {
auto result = execute(_baseCommand ~ ["rev-parse", "--git-dir"]);
!force && !result.status &&
@ -84,9 +100,11 @@ class Snag {
return;
}
writeln("The following list of files requires backup:");
result.output.split('\n').filter!(e => !e.strip.empty).each!((e) {
writefln("\t/%s", e.strip.split[1]);
});
result.output.split('\n')[0..$-1].map!(e =>
e.strip.split
).each!(e =>
writefln("\t%s\t/%s", gitStatus(e[0], true), e[1])
);
}
void create(string comment, string author, string email) {