• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

CLI interface to medialist (fossil mirror)


Commit MetaInfo

修订版849578ee4087d19282c14accae76eae71b02594c (tree)
时间2023-03-14 10:19:18
作者mio <stigma@disr...>
Commitermio

Log Message

Update main.d to use nothrow ml_send_command

FossilOrigin-Name: f5886103bae1f0aff14431a56cc08af9b49b5b4648da9321f5615bb8994ee7c8

更改概述

差异

--- a/main.d
+++ b/main.d
@@ -36,7 +36,7 @@ import mlib.trash : trash;
3636 import medialist;
3737 import util : expandEnvironmentVariables;
3838
39-enum MediaListCLIVersion = "0.4-pre (2023-02-23)";
39+enum MediaListCLIVersion = "0.4-dev";
4040
4141 @trusted void display_usage(string name)
4242 {
@@ -101,7 +101,7 @@ Commands:
101101 Report bugs to <stigma+mlcli@disroot.org>.
102102 View current bugs: <https://rocketgit.com/user/dawning/medialist-cli/bug>
103103 medialist-cli web page: <https://yume-neru.neocities.org/p/medialist.html>",
104- name);
104+ name);
105105 }
106106
107107 /**
@@ -278,9 +278,10 @@ private bool addToList(MediaList* list, string[] args)
278278 }
279279 }
280280
281- MLError err = ml_send_command(list, MLCommand.add, [title, progress, status]);
281+ MLError error;
282+ ml_send_command(list, MLCommand.add, [title, progress, status], error);
282283
283- if (MLError.success != err) {
284+ if (MLError.success != error) {
284285 stderr.writefln("ERROR: Failed to add %s to %s.", title, list.listName);
285286 stderr.writeln("ISSUE: List is already open for editing.");
286287 return false;
@@ -347,19 +348,20 @@ private bool updateListItem(MediaList* list, string[] args)
347348 }
348349 }
349350
350- MLError res = ml_send_command(list, MLCommand.update, commandArgs);
351+ MLError error;
352+ ml_send_command(list, MLCommand.update, commandArgs, error);
351353
352- if (MLError.success != res) {
354+ if (MLError.success != error) {
353355 /* This can only be because the list is open. */
354356 stderr.writefln("ERROR: Failed to update list %s.", list.listName);
355357 stderr.writeln("ISSUE: List is already open for editing.");
356358 return false;
357359 }
358360
359- MediaListItem item = ml_fetch_item(list, id, res);
361+ MediaListItem item = ml_fetch_item(list, id, error);
360362
361- if (MLError.success != res) {
362- switch (res) {
363+ if (MLError.success != error) {
364+ switch (error) {
363365 case MLError.itemNotFound:
364366 /* id doesn't exist. no item was updated. */
365367 stderr.writefln("ERROR: Failed to update list %s.", list.listName);
@@ -463,11 +465,11 @@ private bool deleteFromList(MediaList* list, bool shouldVerifyDelete, string[] a
463465 }
464466 idx += 1;
465467 }
466- err = ml_send_command(list, MLCommand.delete_, cmdArgs);
468+ ml_send_command(list, MLCommand.delete_, cmdArgs, err);
467469 }
468470 else
469471 {
470- err = ml_send_command(list, MLCommand.delete_, args);
472+ ml_send_command(list, MLCommand.delete_, args, err);
471473 }
472474
473475 if (MLError.success == err)
@@ -823,7 +825,7 @@ private bool updateFileItems(MediaListItem[] imported, string listPath, bool ove
823825 "start_date::" ~ item.startDate,
824826 "end_date::" ~ item.endDate
825827 ];
826- error = ml_send_command(list, MLCommand.update, commandArguments);
828+ ml_send_command(list, MLCommand.update, commandArguments, error);
827829
828830 if (MLError.invalidArgs == error) {
829831 logf("import: failed %sItems", overwrite ? "overwrite" : "update");
@@ -839,22 +841,22 @@ private bool updateFileItems(MediaListItem[] imported, string listPath, bool ove
839841 }
840842
841843 foreach(index, item; newItems) {
842- error = ml_send_command(list, MLCommand.add, [
844+ ml_send_command(list, MLCommand.add, [
843845 item.title,
844846 item.progress,
845847 item.status
846- ]);
848+ ], error);
847849
848850 if (MLError.invalidArgs == error) {
849851 stderr.writefln("Failed to add new '%s'", item.title);
850852 continue;
851853 }
852854
853- error = ml_send_command(list, MLCommand.update,[
855+ ml_send_command(list, MLCommand.update,[
854856 to!string(existing.length + index + 1),
855857 "start_date::" ~ item.startDate,
856858 "end_date::" ~ item.endDate
857- ]);
859+ ], error);
858860
859861 if (MLError.invalidArgs == error) {
860862 stderr.writefln("Failed to finish adding '%s'", item.title);