|
2 | 2 |
|
3 | 3 | import org.hydev.mcpm.client.display.presenters.ListPresenter;
|
4 | 4 | import org.hydev.mcpm.client.list.ListAllBoundary;
|
5 |
| -import org.hydev.mcpm.client.models.PluginYml; |
| 5 | + |
6 | 6 | import org.hydev.mcpm.client.updater.CheckForUpdatesBoundary;
|
7 | 7 | import org.hydev.mcpm.client.list.ListType;
|
8 | 8 | import org.hydev.mcpm.client.list.ListResult;
|
9 |
| -import org.hydev.mcpm.client.commands.presenters.ListResultPresenter; |
10 | 9 |
|
11 |
| -import java.util.List; |
12 |
| -import java.util.function.Consumer; |
13 | 10 |
|
14 |
| -import static org.hydev.mcpm.client.display.presenters.Table.tabulate; |
| 11 | + |
| 12 | +import java.util.function.Consumer; |
15 | 13 |
|
16 | 14 | /**
|
17 | 15 | * Controller class for the ListAll use case.
|
@@ -43,35 +41,28 @@ public void listAll(String parameter, Consumer<String> log) {
|
43 | 41 | ListPresenter listPresenter = new ListPresenter(log);
|
44 | 42 | ListType listType;
|
45 | 43 | switch (parameter.toLowerCase()) {
|
46 |
| - case "all": |
47 |
| - listType = ListType.ALL; |
48 |
| - break; |
49 |
| - case "manual": |
50 |
| - listType = ListType.MANUAL; |
51 |
| - break; |
52 |
| - case "automatic": |
53 |
| - listType = ListType.AUTOMATIC; |
54 |
| - break; |
55 |
| - case "outdated": |
56 |
| - listType = ListType.OUTDATED; |
57 |
| - break; |
58 |
| - default: |
| 44 | + case "all" -> listType = ListType.ALL; |
| 45 | + case "manual" -> listType = ListType.MANUAL; |
| 46 | + case "automatic" -> listType = ListType.AUTOMATIC; |
| 47 | + case "outdated" -> listType = ListType.OUTDATED; |
| 48 | + default -> { |
59 | 49 | ListResult queryResult = new ListResult(null, ListResult.Type.SEARCH_INVALID_INPUT);
|
60 | 50 | listPresenter.displayResult(queryResult);
|
61 | 51 | return;
|
| 52 | + } |
62 | 53 | }
|
63 | 54 |
|
64 | 55 | try {
|
65 | 56 | var list = listAllBoundary.listAll(listType);
|
66 | 57 |
|
67 | 58 | // if list is empty
|
| 59 | + ListResult queryResult; |
68 | 60 | if (list.isEmpty()) {
|
69 |
| - ListResult queryResult = new ListResult(list, ListResult.Type.SUCCESS_RETRIEVING_BUT_NO_MATCHES); |
70 |
| - listPresenter.displayResult(queryResult); |
| 61 | + queryResult = new ListResult(list, ListResult.Type.SUCCESS_RETRIEVING_BUT_NO_MATCHES); |
71 | 62 | } else {
|
72 |
| - ListResult queryResult = new ListResult(list, ListResult.Type.SUCCESS_RETRIEVING_LOCAL_AND_UPDATABLE); |
73 |
| - listPresenter.displayResult(queryResult); |
| 63 | + queryResult = new ListResult(list, ListResult.Type.SUCCESS_RETRIEVING_LOCAL_AND_UPDATABLE); |
74 | 64 | }
|
| 65 | + listPresenter.displayResult(queryResult); |
75 | 66 | } catch (Exception e) {
|
76 | 67 | ListResult queryResult = new ListResult(null, ListResult.Type.SEARCH_FAILED_TO_FETCH_INSTALLED);
|
77 | 68 | listPresenter.displayResult(queryResult);
|
|
0 commit comments