Anonymous user
Simple database: Difference between revisions
D entry: all functions now are module-private.
(D entry: shorter lines, modules themselves are namespaces, small formatting changes) |
(D entry: all functions now are module-private.) |
||
Line 640:
std.file, std.csv, std.datetime;
private immutable filename = "simdb.csv";
private struct Item {
string name, date, category;
}
private void addItem(in string[] item) {
if (item.length < 3)
return printUsage();
Line 655 ⟶ 656:
}
private void printLatest(in string[] a) {
auto db = load();
if (db.empty)
Line 669 ⟶ 670:
}
private void printAll() {
auto db = load();
if (db.empty)
Line 678 ⟶ 679:
}
private Item[] load() {
Item[] db;
if (filename.exists && filename.isFile) {
Line 692 ⟶ 693:
}
private void store(in Item[] db) {
auto f = File(filename, "w+");
foreach (item; db)
Line 698 ⟶ 699:
}
private void printUsage() {
writeln(
`Usage:
|