CLI interface to medialist (fossil mirror)
Revisão | 849578ee4087d19282c14accae76eae71b02594c (tree) |
---|---|
Hora | 2023-03-14 10:19:18 |
Autor | mio <stigma@disr...> |
Commiter | mio |
Update main.d to use nothrow ml_send_command
FossilOrigin-Name: f5886103bae1f0aff14431a56cc08af9b49b5b4648da9321f5615bb8994ee7c8
@@ -36,7 +36,7 @@ import mlib.trash : trash; | ||
36 | 36 | import medialist; |
37 | 37 | import util : expandEnvironmentVariables; |
38 | 38 | |
39 | -enum MediaListCLIVersion = "0.4-pre (2023-02-23)"; | |
39 | +enum MediaListCLIVersion = "0.4-dev"; | |
40 | 40 | |
41 | 41 | @trusted void display_usage(string name) |
42 | 42 | { |
@@ -101,7 +101,7 @@ Commands: | ||
101 | 101 | Report bugs to <stigma+mlcli@disroot.org>. |
102 | 102 | View current bugs: <https://rocketgit.com/user/dawning/medialist-cli/bug> |
103 | 103 | medialist-cli web page: <https://yume-neru.neocities.org/p/medialist.html>", |
104 | - name); | |
104 | + name); | |
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -278,9 +278,10 @@ private bool addToList(MediaList* list, string[] args) | ||
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
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); | |
282 | 283 | |
283 | - if (MLError.success != err) { | |
284 | + if (MLError.success != error) { | |
284 | 285 | stderr.writefln("ERROR: Failed to add %s to %s.", title, list.listName); |
285 | 286 | stderr.writeln("ISSUE: List is already open for editing."); |
286 | 287 | return false; |
@@ -347,19 +348,20 @@ private bool updateListItem(MediaList* list, string[] args) | ||
347 | 348 | } |
348 | 349 | } |
349 | 350 | |
350 | - MLError res = ml_send_command(list, MLCommand.update, commandArgs); | |
351 | + MLError error; | |
352 | + ml_send_command(list, MLCommand.update, commandArgs, error); | |
351 | 353 | |
352 | - if (MLError.success != res) { | |
354 | + if (MLError.success != error) { | |
353 | 355 | /* This can only be because the list is open. */ |
354 | 356 | stderr.writefln("ERROR: Failed to update list %s.", list.listName); |
355 | 357 | stderr.writeln("ISSUE: List is already open for editing."); |
356 | 358 | return false; |
357 | 359 | } |
358 | 360 | |
359 | - MediaListItem item = ml_fetch_item(list, id, res); | |
361 | + MediaListItem item = ml_fetch_item(list, id, error); | |
360 | 362 | |
361 | - if (MLError.success != res) { | |
362 | - switch (res) { | |
363 | + if (MLError.success != error) { | |
364 | + switch (error) { | |
363 | 365 | case MLError.itemNotFound: |
364 | 366 | /* id doesn't exist. no item was updated. */ |
365 | 367 | stderr.writefln("ERROR: Failed to update list %s.", list.listName); |
@@ -463,11 +465,11 @@ private bool deleteFromList(MediaList* list, bool shouldVerifyDelete, string[] a | ||
463 | 465 | } |
464 | 466 | idx += 1; |
465 | 467 | } |
466 | - err = ml_send_command(list, MLCommand.delete_, cmdArgs); | |
468 | + ml_send_command(list, MLCommand.delete_, cmdArgs, err); | |
467 | 469 | } |
468 | 470 | else |
469 | 471 | { |
470 | - err = ml_send_command(list, MLCommand.delete_, args); | |
472 | + ml_send_command(list, MLCommand.delete_, args, err); | |
471 | 473 | } |
472 | 474 | |
473 | 475 | if (MLError.success == err) |
@@ -823,7 +825,7 @@ private bool updateFileItems(MediaListItem[] imported, string listPath, bool ove | ||
823 | 825 | "start_date::" ~ item.startDate, |
824 | 826 | "end_date::" ~ item.endDate |
825 | 827 | ]; |
826 | - error = ml_send_command(list, MLCommand.update, commandArguments); | |
828 | + ml_send_command(list, MLCommand.update, commandArguments, error); | |
827 | 829 | |
828 | 830 | if (MLError.invalidArgs == error) { |
829 | 831 | logf("import: failed %sItems", overwrite ? "overwrite" : "update"); |
@@ -839,22 +841,22 @@ private bool updateFileItems(MediaListItem[] imported, string listPath, bool ove | ||
839 | 841 | } |
840 | 842 | |
841 | 843 | foreach(index, item; newItems) { |
842 | - error = ml_send_command(list, MLCommand.add, [ | |
844 | + ml_send_command(list, MLCommand.add, [ | |
843 | 845 | item.title, |
844 | 846 | item.progress, |
845 | 847 | item.status |
846 | - ]); | |
848 | + ], error); | |
847 | 849 | |
848 | 850 | if (MLError.invalidArgs == error) { |
849 | 851 | stderr.writefln("Failed to add new '%s'", item.title); |
850 | 852 | continue; |
851 | 853 | } |
852 | 854 | |
853 | - error = ml_send_command(list, MLCommand.update,[ | |
855 | + ml_send_command(list, MLCommand.update,[ | |
854 | 856 | to!string(existing.length + index + 1), |
855 | 857 | "start_date::" ~ item.startDate, |
856 | 858 | "end_date::" ~ item.endDate |
857 | - ]); | |
859 | + ], error); | |
858 | 860 | |
859 | 861 | if (MLError.invalidArgs == error) { |
860 | 862 | stderr.writefln("Failed to finish adding '%s'", item.title); |