CLI interface to medialist (fossil mirror)
修訂 | 36e852a57da77146d3d17bb95234975cebd50e8c (tree) |
---|---|
時間 | 2023-03-28 16:28:12 |
作者 | mio <stigma@disr...> |
Commiter | mio |
Update main.d to remove deprecation warnings from mlib
FossilOrigin-Name: 6a812b90dbb08dae2a99418d2482fd41bef0bb6be8fa09254b52620d8bc527a0
@@ -1,7 +1,10 @@ | ||
1 | 1 | *.o |
2 | +*.a | |
2 | 3 | *.html |
3 | 4 | *.txt |
4 | 5 | *.json |
5 | 6 | |
6 | 7 | *.aux |
7 | 8 | *~ |
9 | + | |
10 | +medialist-cli |
@@ -1048,10 +1048,9 @@ private bool importList(string data_dir, string[] args) { | ||
1048 | 1048 | /// |
1049 | 1049 | /// Setup the logger for medialist-cli. |
1050 | 1050 | /// |
1051 | -void setupLogger() | |
1051 | +void setupLogger(in ref ProjectDirectories projectDirs) | |
1052 | 1052 | { |
1053 | - DirEntry stateEntry = open(Directory.state); | |
1054 | - string logDirPath = buildPath(stateEntry.name, "medialist-cli"); | |
1053 | + string logDirPath = projectDirs.cacheDir; | |
1055 | 1054 | |
1056 | 1055 | if (false == exists(logDirPath)) { |
1057 | 1056 | mkdirRecurse(logDirPath); |
@@ -1076,11 +1075,10 @@ void setupLogger() | ||
1076 | 1075 | } |
1077 | 1076 | |
1078 | 1077 | int main(string[] args) { |
1079 | - DirEntry configEntry = open(Directory.config); | |
1080 | - DirEntry dataEntry = open(Directory.data); | |
1078 | + // idk? will think of something | |
1079 | + ProjectDirectories projectDirs = getProjectDirectories(null, "YumeNeru Productions", "medialist"); | |
1080 | + string dataDirectory = projectDirs.dataDir; // default directory. | |
1081 | 1081 | |
1082 | - string config_dir = buildPath(configEntry.name, "medialist"); | |
1083 | - string data_dir = buildPath(dataEntry.name, "medialist"); | |
1084 | 1082 | string command = "help"; |
1085 | 1083 | |
1086 | 1084 | version(appimage) { |
@@ -1089,7 +1087,7 @@ version(appimage) { | ||
1089 | 1087 | string program_name = args[0]; |
1090 | 1088 | } |
1091 | 1089 | |
1092 | - setupLogger(); | |
1090 | + setupLogger(projectDirs); | |
1093 | 1091 | |
1094 | 1092 | bool success = true; |
1095 | 1093 | /* Default behaviour since 0.3 */ |
@@ -1125,15 +1123,15 @@ version(appimage) { | ||
1125 | 1123 | } |
1126 | 1124 | |
1127 | 1125 | command = args[1]; |
1128 | - mkdirRecurse(config_dir); | |
1126 | + mkdirRecurse(projectDirs.configDir); | |
1129 | 1127 | |
1130 | - if (buildPath(config_dir, "medialist.conf").exists) { | |
1131 | - scope contents = readText(buildPath(config_dir, "medialist.conf")); | |
1128 | + if (buildPath(projectDirs.configDir, "medialist.conf").exists) { | |
1129 | + scope contents = readText(buildPath(projectDirs.configDir, "medialist.conf")); | |
1132 | 1130 | auto conf = CniParser.fromString(contents, CniOptions(false, true)); |
1133 | 1131 | |
1134 | 1132 | if ("general.directory" in conf) { |
1135 | 1133 | trace("Using >=0.3 configuration section"); |
1136 | - data_dir = conf["general.directory"]; | |
1134 | + dataDirectory = conf["general.directory"]; | |
1137 | 1135 | } else if ("Lists.directory" in conf) { |
1138 | 1136 | /* |
1139 | 1137 | * COMPAT: For pre-0.2 versions of medialist. No need to remove, |
@@ -1143,10 +1141,10 @@ version(appimage) { | ||
1143 | 1141 | stderr.writeln(`WARNING: Using the "Lists" section in your configuration is deprecated.`); |
1144 | 1142 | stderr.writeln(` Please change to using the "general" section.`); |
1145 | 1143 | stderr.writeln(` This warning (along with support for "Lists") will be removed v0.5`); |
1146 | - data_dir = conf["Lists.directory"]; | |
1144 | + dataDirectory = conf["Lists.directory"]; | |
1147 | 1145 | } |
1148 | 1146 | |
1149 | - data_dir = expandEnvironmentVariables(expandTilde(data_dir)); | |
1147 | + dataDirectory = expandEnvironmentVariables(expandTilde(dataDirectory)); | |
1150 | 1148 | |
1151 | 1149 | string shouldVerifyDeleteRaw; |
1152 | 1150 |
@@ -1163,16 +1161,16 @@ version(appimage) { | ||
1163 | 1161 | } |
1164 | 1162 | } |
1165 | 1163 | |
1166 | - mkdirRecurse(data_dir); | |
1164 | + mkdirRecurse(dataDirectory); | |
1167 | 1165 | |
1168 | 1166 | if ("import" == command) { |
1169 | 1167 | trace(`Command: import`); |
1170 | - success = importList(data_dir, args[2..$]); | |
1168 | + success = importList(dataDirectory, args[2..$]); | |
1171 | 1169 | return success ? EXIT_SUCCESS : EXIT_FAILURE; |
1172 | 1170 | } |
1173 | 1171 | |
1174 | 1172 | /* temporary mess while changing to the library format */ |
1175 | - string filePath = buildPath(data_dir, args[2] ~ ".tsv"); | |
1173 | + string filePath = buildPath(dataDirectory, args[2] ~ ".tsv"); | |
1176 | 1174 | MediaList *ml = null; |
1177 | 1175 | |
1178 | 1176 | if (false == exists(filePath)) { |