update: better logging and search improvements
This commit is contained in:
parent
86b1481774
commit
4f4db1963d
2
Makefile
2
Makefile
@ -11,7 +11,7 @@ OBJS = $(patsubst src/%.c,dist/%.o,$(SRCS))
|
||||
CFLAGS = -O3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection
|
||||
LIBS = -linih -lmp
|
||||
|
||||
VERSION = 24.01
|
||||
VERSION = 24.02
|
||||
|
||||
all: dist dist/matt $(PO_OUTS)
|
||||
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-08-22 02:15+0300\n"
|
||||
"POT-Creation-Date: 2024-08-22 03:32+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -17,11 +17,11 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: src/callback.c:34 src/callback.c:49
|
||||
#: src/callback.c:36 src/callback.c:53
|
||||
msgid "Failed to sync "
|
||||
msgstr "Failed to sync "
|
||||
|
||||
#: src/callback.c:43 src/cmd/sync.c:32
|
||||
#: src/callback.c:47 src/cmd/sync.c:46
|
||||
msgid "Synced "
|
||||
msgstr "Synced "
|
||||
|
||||
@ -155,7 +155,9 @@ msgstr "Displaying help information"
|
||||
msgid "MatterLinux package manager %s (libmp %s)"
|
||||
msgstr "MatterLinux package manager %s (libmp %s)"
|
||||
|
||||
#: src/main.c:188
|
||||
#: src/main.c:188 src/cmd/info.c:47 src/cmd/install.c:33 src/cmd/list.c:23
|
||||
#: src/cmd/remove.c:27 src/cmd/search.c:197 src/cmd/sync.c:23
|
||||
#: src/cmd/update.c:22
|
||||
msgid "Usage: "
|
||||
msgstr "Usage: "
|
||||
|
||||
@ -171,17 +173,18 @@ msgstr "To list different options, use commands with "
|
||||
msgid "Here is a list of available global options:"
|
||||
msgstr "Here is a list of available global options:"
|
||||
|
||||
#: src/main.c:200 src/main.c:201 src/cmd/info.c:48 src/cmd/info.c:49
|
||||
#: src/cmd/info.c:50 src/cmd/install.c:34 src/cmd/install.c:35
|
||||
#: src/main.c:200 src/main.c:201 src/main.c:202 src/cmd/info.c:49
|
||||
#: src/cmd/info.c:50 src/cmd/info.c:51 src/cmd/install.c:35
|
||||
#: src/cmd/install.c:36 src/cmd/install.c:37 src/cmd/install.c:38
|
||||
#: src/cmd/list.c:24 src/cmd/list.c:25 src/cmd/remove.c:28 src/cmd/remove.c:29
|
||||
#: src/cmd/search.c:170 src/cmd/search.c:171 src/cmd/search.c:172
|
||||
#: src/cmd/search.c:173 src/cmd/update.c:23
|
||||
#: src/cmd/install.c:39 src/cmd/list.c:25 src/cmd/list.c:26 src/cmd/remove.c:29
|
||||
#: src/cmd/remove.c:30 src/cmd/search.c:199 src/cmd/search.c:200
|
||||
#: src/cmd/search.c:201 src/cmd/search.c:202 src/cmd/sync.c:25
|
||||
#: src/cmd/update.c:24
|
||||
#, c-format
|
||||
msgid " "
|
||||
msgstr " "
|
||||
|
||||
#: src/main.c:203
|
||||
#: src/main.c:204
|
||||
msgid ""
|
||||
"Licensed under GPLv3, see https://www.gnu.org/licenses/ for more information"
|
||||
msgstr ""
|
||||
@ -201,235 +204,240 @@ msgstr "Failed to run the editor: %s"
|
||||
msgid "Failed to open the editor: %s"
|
||||
msgstr "Failed to open the editor: %s"
|
||||
|
||||
#: src/cmd/info.c:13 src/cmd/info.c:23 src/cmd/install.c:91 src/cmd/remove.c:52
|
||||
#: src/cmd/info.c:13 src/cmd/info.c:23 src/cmd/install.c:92 src/cmd/remove.c:53
|
||||
msgid "Package "
|
||||
msgstr "Package "
|
||||
|
||||
#: src/cmd/info.c:42 src/cmd/install.c:28 src/cmd/list.c:18 src/cmd/remove.c:22
|
||||
#: src/cmd/search.c:164 src/cmd/sync.c:15 src/cmd/update.c:17
|
||||
#: src/cmd/search.c:192 src/cmd/sync.c:18 src/cmd/update.c:17
|
||||
msgid "Unknown argument: "
|
||||
msgstr "Unknown argument: "
|
||||
|
||||
#: src/cmd/info.c:47 src/cmd/list.c:23 src/cmd/search.c:169
|
||||
#: src/cmd/info.c:48 src/cmd/list.c:24 src/cmd/search.c:198 src/cmd/sync.c:24
|
||||
msgid "Listing options for the list command:"
|
||||
msgstr "Listing options for the list command:"
|
||||
|
||||
#: src/cmd/info.c:71
|
||||
#: src/cmd/info.c:72
|
||||
msgid "Please specify only a single package name"
|
||||
msgstr "Please specify only a single package name"
|
||||
|
||||
#: src/cmd/info.c:78
|
||||
#: src/cmd/info.c:79
|
||||
msgid "Please specify a single package"
|
||||
msgstr "Please specify a single package"
|
||||
|
||||
#: src/cmd/info.c:93
|
||||
#: src/cmd/info.c:94
|
||||
msgid "Failed to get the changes file for "
|
||||
msgstr "Failed to get the changes file for "
|
||||
|
||||
#: src/cmd/info.c:99
|
||||
#: src/cmd/info.c:100
|
||||
msgid "Failed to access the changes file, is the package installed?"
|
||||
msgstr "Failed to access the changes file, is the package installed?"
|
||||
|
||||
#: src/cmd/info.c:106
|
||||
#: src/cmd/info.c:107
|
||||
msgid "Failed to get the depends list for "
|
||||
msgstr "Failed to get the depends list for "
|
||||
|
||||
#: src/cmd/info.c:134
|
||||
#: src/cmd/info.c:135
|
||||
#, c-format
|
||||
msgid "Name "
|
||||
msgstr "Name "
|
||||
|
||||
#: src/cmd/info.c:135
|
||||
#: src/cmd/info.c:136
|
||||
#, c-format
|
||||
msgid "Version "
|
||||
msgstr "Version "
|
||||
|
||||
#: src/cmd/info.c:136
|
||||
#: src/cmd/info.c:137
|
||||
#, c-format
|
||||
msgid "Desc "
|
||||
msgstr "Desc "
|
||||
|
||||
#: src/cmd/info.c:137
|
||||
#: src/cmd/info.c:138
|
||||
#, c-format
|
||||
msgid "Size "
|
||||
msgstr "Size "
|
||||
|
||||
#: src/cmd/info.c:140
|
||||
#: src/cmd/info.c:141
|
||||
#, c-format
|
||||
msgid "Depends "
|
||||
msgstr "Depends "
|
||||
|
||||
#: src/cmd/info.c:143
|
||||
#: src/cmd/info.c:144
|
||||
#, c-format
|
||||
msgid "Changes "
|
||||
msgstr "Changes "
|
||||
|
||||
#: src/cmd/info.c:146
|
||||
#: src/cmd/info.c:147
|
||||
#, fuzzy, c-format
|
||||
msgid "Pool "
|
||||
msgstr " "
|
||||
|
||||
#: src/cmd/info.c:149 src/cmd/info.c:150
|
||||
#: src/cmd/info.c:150 src/cmd/info.c:151
|
||||
#, c-format
|
||||
msgid "Installed "
|
||||
msgstr "Installed "
|
||||
|
||||
#: src/cmd/info.c:153 src/cmd/info.c:154
|
||||
#: src/cmd/info.c:154 src/cmd/info.c:155
|
||||
#, c-format
|
||||
msgid "Up-to-date "
|
||||
msgstr "Up-to-date "
|
||||
|
||||
#: src/cmd/install.c:33
|
||||
#: src/cmd/install.c:34
|
||||
msgid "Listing options for the install command:"
|
||||
msgstr "Listing options for the install command:"
|
||||
|
||||
#: src/cmd/install.c:43 src/cmd/update.c:28
|
||||
#: src/cmd/install.c:44 src/cmd/update.c:29
|
||||
msgid "There are no avaliable pools, have you synced yet?"
|
||||
msgstr "There are no avaliable pools, have you synced yet?"
|
||||
|
||||
#: src/cmd/install.c:62
|
||||
#: src/cmd/install.c:63
|
||||
msgid "Specified "
|
||||
msgstr "Specified "
|
||||
|
||||
#: src/cmd/install.c:72
|
||||
#: src/cmd/install.c:73
|
||||
msgid "Failed to load "
|
||||
msgstr "Failed to load "
|
||||
|
||||
#: src/cmd/install.c:82 src/cmd/remove.c:54
|
||||
#: src/cmd/install.c:83 src/cmd/remove.c:55
|
||||
msgid "Failed to find "
|
||||
msgstr "Failed to find "
|
||||
|
||||
#: src/cmd/install.c:100
|
||||
#: src/cmd/install.c:101
|
||||
msgid "Failed to resolve "
|
||||
msgstr "Failed to resolve "
|
||||
|
||||
#: src/cmd/install.c:109
|
||||
#: src/cmd/install.c:110
|
||||
msgid "Nothing to do (no packages to install)"
|
||||
msgstr "Nothing to do (no packages to install)"
|
||||
|
||||
#: src/cmd/install.c:118 src/cmd/install.c:120 src/cmd/remove.c:74
|
||||
#: src/cmd/remove.c:76 src/cmd/update.c:49 src/cmd/update.c:51
|
||||
#: src/cmd/install.c:119 src/cmd/install.c:121 src/cmd/remove.c:75
|
||||
#: src/cmd/remove.c:77 src/cmd/update.c:50 src/cmd/update.c:52
|
||||
msgid "Following "
|
||||
msgstr "Following "
|
||||
|
||||
#: src/cmd/install.c:126 src/cmd/remove.c:83
|
||||
#: src/cmd/install.c:127 src/cmd/remove.c:84
|
||||
msgid "Total of "
|
||||
msgstr "Total of "
|
||||
|
||||
#: src/cmd/install.c:129 src/cmd/update.c:58
|
||||
#: src/cmd/install.c:130 src/cmd/update.c:59
|
||||
#, c-format
|
||||
msgid "Root directory is modified, install scripts will be saved in %s"
|
||||
msgstr "Root directory is modified, install scripts will be saved in %s"
|
||||
|
||||
#: src/cmd/install.c:131 src/cmd/remove.c:84 src/cmd/update.c:60
|
||||
#: src/cmd/install.c:132 src/cmd/remove.c:85 src/cmd/update.c:61
|
||||
msgid "Continue?"
|
||||
msgstr "Continue?"
|
||||
|
||||
#: src/cmd/install.c:132 src/cmd/remove.c:85 src/cmd/update.c:61
|
||||
#: src/cmd/install.c:133 src/cmd/remove.c:86 src/cmd/update.c:62
|
||||
msgid "Operation cancelled"
|
||||
msgstr "Operation cancelled"
|
||||
|
||||
#: src/cmd/install.c:148 src/cmd/install.c:152 src/cmd/install.c:172
|
||||
#: src/cmd/install.c:188 src/cmd/remove.c:92 src/cmd/update.c:71
|
||||
#: src/cmd/update.c:82 src/cmd/update.c:93
|
||||
#: src/cmd/install.c:149 src/cmd/install.c:153 src/cmd/install.c:173
|
||||
#: src/cmd/install.c:189 src/cmd/remove.c:93 src/cmd/update.c:72
|
||||
#: src/cmd/update.c:83 src/cmd/update.c:94
|
||||
msgid "("
|
||||
msgstr "("
|
||||
|
||||
#: src/cmd/install.c:158 src/cmd/update.c:77
|
||||
#: src/cmd/install.c:159 src/cmd/update.c:78
|
||||
msgid "Failed to download "
|
||||
msgstr "Failed to download "
|
||||
|
||||
#: src/cmd/install.c:179 src/cmd/remove.c:99 src/cmd/update.c:88
|
||||
#: src/cmd/install.c:180 src/cmd/remove.c:100 src/cmd/update.c:89
|
||||
msgid "Failed to remove "
|
||||
msgstr "Failed to remove "
|
||||
|
||||
#: src/cmd/install.c:195 src/cmd/update.c:99
|
||||
#: src/cmd/install.c:196 src/cmd/update.c:100
|
||||
msgid "Failed to install "
|
||||
msgstr "Failed to install "
|
||||
|
||||
#: src/cmd/install.c:202
|
||||
#: src/cmd/install.c:203
|
||||
msgid "Installed "
|
||||
msgstr "Installed "
|
||||
|
||||
#: src/cmd/install.c:202
|
||||
#: src/cmd/install.c:203
|
||||
msgid "Installed all of the "
|
||||
msgstr "Installed all of the "
|
||||
|
||||
#: src/cmd/list.c:38
|
||||
#: src/cmd/list.c:39
|
||||
#, fuzzy
|
||||
msgid "There are no installed packages"
|
||||
msgstr "There no installed packages"
|
||||
|
||||
#: src/cmd/list.c:43
|
||||
#: src/cmd/list.c:44
|
||||
msgid "Listing "
|
||||
msgstr "Listing "
|
||||
|
||||
#: src/cmd/remove.c:27
|
||||
#: src/cmd/remove.c:28
|
||||
msgid "Listing options for the remove command:"
|
||||
msgstr "Listing options for the remove command:"
|
||||
|
||||
#: src/cmd/remove.c:59
|
||||
#: src/cmd/remove.c:60
|
||||
#, fuzzy
|
||||
msgid "Cannot remove "
|
||||
msgstr "Failed to remove "
|
||||
|
||||
#: src/cmd/remove.c:67
|
||||
#: src/cmd/remove.c:68
|
||||
msgid "Nothing to do (no packages to remove)"
|
||||
msgstr "Nothing to do (no packages to remove)"
|
||||
|
||||
#: src/cmd/remove.c:106
|
||||
#: src/cmd/remove.c:107
|
||||
msgid "Removed "
|
||||
msgstr "Removed "
|
||||
|
||||
#: src/cmd/remove.c:106
|
||||
#: src/cmd/remove.c:107
|
||||
msgid "Removed all of the "
|
||||
msgstr "Removed all of the "
|
||||
|
||||
#: src/cmd/search.c:49 src/cmd/search.c:120
|
||||
msgid "No results"
|
||||
#: src/cmd/search.c:72 src/cmd/search.c:149
|
||||
msgid "No results, maybe you forgot to sync?"
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/search.c:54 src/cmd/search.c:125
|
||||
#: src/cmd/search.c:77 src/cmd/search.c:154
|
||||
msgid "Found "
|
||||
msgstr ""
|
||||
|
||||
#: src/cmd/search.c:90
|
||||
#: src/cmd/search.c:113
|
||||
#, fuzzy, c-format
|
||||
msgid "Failed to load package pools: %s"
|
||||
msgstr "Failed to get the package update list: %s"
|
||||
|
||||
#: src/cmd/search.c:119
|
||||
#, fuzzy, c-format
|
||||
msgid "Failed to get package list: %s"
|
||||
msgstr "Failed to get the package update list: %s"
|
||||
|
||||
#: src/cmd/search.c:189
|
||||
#: src/cmd/search.c:218
|
||||
#, fuzzy
|
||||
msgid "Please specify only a single value for searching"
|
||||
msgid "Please specify only a single query for searching"
|
||||
msgstr "Please specify only a single package name"
|
||||
|
||||
#: src/cmd/search.c:196
|
||||
#: src/cmd/search.c:225
|
||||
#, fuzzy
|
||||
msgid "Please specify a value for searching"
|
||||
msgid "Please specify a query for searching"
|
||||
msgstr "Please specify a single package"
|
||||
|
||||
#: src/cmd/sync.c:20
|
||||
#: src/cmd/sync.c:30
|
||||
msgid "There are no pools specified in the configuration"
|
||||
msgstr "There are no pools specified in the configuration"
|
||||
|
||||
#: src/cmd/sync.c:28
|
||||
#: src/cmd/sync.c:39
|
||||
#, c-format
|
||||
msgid "Failed to sync pools: %s"
|
||||
msgstr "Failed to sync pools: %s"
|
||||
|
||||
#: src/cmd/update.c:22
|
||||
#: src/cmd/update.c:23
|
||||
msgid "Listing options for the update command:"
|
||||
msgstr "Listing options for the update command:"
|
||||
|
||||
#: src/cmd/update.c:39
|
||||
#: src/cmd/update.c:40
|
||||
#, c-format
|
||||
msgid "Failed to get the package update list: %s"
|
||||
msgstr "Failed to get the package update list: %s"
|
||||
|
||||
#: src/cmd/update.c:44
|
||||
#: src/cmd/update.c:45
|
||||
msgid "All packages are up-to-date"
|
||||
msgstr "All packages are up-to-date"
|
||||
|
||||
#: src/cmd/update.c:67
|
||||
#: src/cmd/update.c:68
|
||||
msgid "Failed to update "
|
||||
msgstr "Failed to update "
|
||||
|
@ -20,6 +20,8 @@ bool callback_remove(lm_ctx_t *ctx, lm_entry_t *ent, char *file, size_t current,
|
||||
|
||||
bool callback_sync(
|
||||
lm_ctx_t *ctx, lm_pool_t *pool, lm_ctx_sync_state_t state, size_t current, size_t total, void *data) {
|
||||
bool fail = *(bool *)data;
|
||||
|
||||
switch (state) {
|
||||
case SYNC_DOWNLOADING_INFO:
|
||||
bar(current, total);
|
||||
@ -32,6 +34,8 @@ bool callback_sync(
|
||||
case SYNC_INFO_FAIL:
|
||||
bar_free();
|
||||
error(_("Failed to sync " FG_BOLD "%s" FG_RESET ": %s"), pool->name, lm_strerror());
|
||||
if (fail)
|
||||
return false;
|
||||
break;
|
||||
|
||||
case SYNC_DOWNLOADING_LIST:
|
||||
@ -47,6 +51,8 @@ bool callback_sync(
|
||||
bar_free();
|
||||
if (LM_ERR_InfoNotLoaded != lm_error())
|
||||
error(_("Failed to sync " FG_BOLD "%s" FG_RESET ": %s"), pool->name, lm_strerror());
|
||||
if (fail)
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ bool cmd_info(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "info <options> [package name]"));
|
||||
info(_("Listing options for the list command:"));
|
||||
printf(_(" "FG_BOLD"--grep"FG_RESET":\tmakes the output \"grepable\"\n"));
|
||||
printf(_(" "FG_BOLD"--changes"FG_RESET":\topen the changes file for the package\n"));
|
||||
|
@ -30,6 +30,7 @@ bool cmd_install(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "install <options> [package name(s)]"));
|
||||
info(_("Listing options for the install command:"));
|
||||
printf(_(" "FG_BOLD"--ignore-depends"FG_RESET":\tignore package dependencies\n"));
|
||||
printf(_(" "FG_BOLD"--ignore-none"FG_RESET":\tignore if there is nothing do\n"));
|
||||
|
@ -20,6 +20,7 @@ bool cmd_list(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "list <options>"));
|
||||
info(_("Listing options for the list command:"));
|
||||
printf(_(" "FG_BOLD"--grep"FG_RESET":\tmakes the output \"grepable\"\n"));
|
||||
printf(_(" "FG_BOLD"--desc"FG_RESET":\tshow package descriptions\n"));
|
||||
|
@ -24,6 +24,7 @@ bool cmd_remove(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "remove <options> [package name(s)]"));
|
||||
info(_("Listing options for the remove command:"));
|
||||
printf(_(" "FG_BOLD"--break"FG_RESET":\tbreak other package depends\n"));
|
||||
printf(_(" "FG_BOLD"--yes"FG_RESET":\tdon't ask for confirmation\n"));
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "../util.h"
|
||||
#include "../intl.h"
|
||||
@ -14,7 +15,29 @@ enum field {
|
||||
FIELD_VERSION = 2,
|
||||
};
|
||||
|
||||
bool cmd_search_database(lm_ctx_t *ctx, args_t *args, char *search, enum field field) {
|
||||
bool contains(char *string, char *search){
|
||||
if(NULL == string || NULL == search)
|
||||
return false;
|
||||
|
||||
size_t string_size = strlen(string);
|
||||
size_t search_size = strlen(search);
|
||||
size_t i = 0;
|
||||
|
||||
char string_lower[string_size+1];
|
||||
char search_lower[search_size+1];
|
||||
|
||||
for(i = 0; i < string_size; i++)
|
||||
string_lower[i] = tolower(string[i]);
|
||||
string_lower[i] = 0;
|
||||
|
||||
for(i = 0; i < search_size; i++)
|
||||
search_lower[i] = tolower(search[i]);
|
||||
search_lower[i] = 0;
|
||||
|
||||
return strstr(string_lower, search_lower) != NULL;
|
||||
}
|
||||
|
||||
bool cmd_search_database(lm_ctx_t *ctx, args_t *args, char *query, enum field field) {
|
||||
lm_entry_t *list = malloc(sizeof(lm_entry_t));
|
||||
char *selected = NULL;
|
||||
size_t indx = 0, i = 0;
|
||||
@ -37,7 +60,7 @@ bool cmd_search_database(lm_ctx_t *ctx, args_t *args, char *search, enum field f
|
||||
break;
|
||||
}
|
||||
|
||||
if(NULL == selected || strstr(selected, search) == NULL)
|
||||
if(!contains(selected, query))
|
||||
continue;
|
||||
|
||||
list = realloc(list, sizeof(lm_entry_t)*((++indx)+1));
|
||||
@ -46,7 +69,7 @@ bool cmd_search_database(lm_ctx_t *ctx, args_t *args, char *search, enum field f
|
||||
|
||||
if(indx <= 0){
|
||||
if(!args_get_bool(args, "grep"))
|
||||
info(_("No results"));
|
||||
info(_("No results, maybe you forgot to sync?"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -76,7 +99,7 @@ end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool cmd_search_pools(lm_ctx_t *ctx, args_t *args, char *search, enum field field) {
|
||||
bool cmd_search_pools(lm_ctx_t *ctx, args_t *args, char *query, enum field field) {
|
||||
lm_pkg_t **list = malloc(sizeof(lm_pkg_t*));
|
||||
char *selected = NULL;
|
||||
size_t indx = 0, i = 0;
|
||||
@ -85,6 +108,12 @@ bool cmd_search_pools(lm_ctx_t *ctx, args_t *args, char *search, enum field fiel
|
||||
|
||||
list[indx] = NULL;
|
||||
|
||||
if(!lm_ctx_sync(ctx, false, NULL, NULL)){
|
||||
if(!args_get_bool(args, "grep"))
|
||||
info(_("Failed to load package pools: %s"), lm_strerror());
|
||||
goto end;
|
||||
}
|
||||
|
||||
if(!lm_ctx_list(ctx, &plist)){
|
||||
if(!args_get_bool(args, "grep"))
|
||||
info(_("Failed to get package list: %s"), lm_strerror());
|
||||
@ -108,7 +137,7 @@ bool cmd_search_pools(lm_ctx_t *ctx, args_t *args, char *search, enum field fiel
|
||||
break;
|
||||
}
|
||||
|
||||
if(NULL == selected || strstr(selected, search) == NULL)
|
||||
if(!contains(selected, query))
|
||||
continue;
|
||||
|
||||
list = realloc(list, sizeof(lm_pkg_t*)*((++indx)+1));
|
||||
@ -117,7 +146,7 @@ bool cmd_search_pools(lm_ctx_t *ctx, args_t *args, char *search, enum field fiel
|
||||
|
||||
if(indx <= 0){
|
||||
if(!args_get_bool(args, "grep"))
|
||||
info(_("No results"));
|
||||
info(_("No results, maybe you forgot to sync?"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -152,7 +181,6 @@ bool cmd_search(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
|
||||
args_split(args, "grep");
|
||||
args_split(args, "desc");
|
||||
args_split(args, "field");
|
||||
args_split(args, "database");
|
||||
|
||||
args_register(args, "grep");
|
||||
@ -166,6 +194,7 @@ bool cmd_search(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "search <options> [query]"));
|
||||
info(_("Listing options for the list command:"));
|
||||
printf(_(" "FG_BOLD"--grep"FG_RESET":\tmakes the output \"grepable\"\n"));
|
||||
printf(_(" "FG_BOLD"--desc"FG_RESET":\tshow package description of the results\n"));
|
||||
@ -175,25 +204,25 @@ bool cmd_search(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
enum field field = FIELD_NAME;
|
||||
char *search = NULL, *field_val = NULL;
|
||||
char *query = NULL, *field_val = NULL;
|
||||
|
||||
for(size_t i = 1; i < args->count; i++){
|
||||
if(NULL != args->list[i].name)
|
||||
continue;
|
||||
|
||||
if(NULL == search && NULL != (search = args->list[i].value))
|
||||
if(NULL == query && NULL != (query = args->list[i].value))
|
||||
continue;
|
||||
|
||||
else if(NULL != search && NULL != (search = args->list[i].value)){
|
||||
else if(NULL != query && NULL != (query = args->list[i].value)){
|
||||
if(!args_get_bool(args, "grep"))
|
||||
error(_("Please specify only a single value for searching"));
|
||||
error(_("Please specify only a single query for searching"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(NULL == search){
|
||||
if(NULL == query){
|
||||
if(!args_get_bool(args, "grep"))
|
||||
error(_("Please specify a value for searching"));
|
||||
error(_("Please specify a query for searching"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -205,7 +234,7 @@ bool cmd_search(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
field = FIELD_VERSION;
|
||||
|
||||
if(args_get_bool(args, "database"))
|
||||
return cmd_search_database(ctx, args, search, field);
|
||||
return cmd_search_pools(ctx, args, search, field);
|
||||
return cmd_search_database(ctx, args, query, field);
|
||||
return cmd_search_pools(ctx, args, query, field);
|
||||
}
|
||||
|
||||
|
@ -7,29 +7,43 @@
|
||||
#include "../log.h"
|
||||
|
||||
bool cmd_sync(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
size_t sycned = 0;
|
||||
bool ret = false;
|
||||
bool ret = false, fail = false;
|
||||
ssize_t synced = 0;
|
||||
char *arg = NULL;
|
||||
|
||||
args_split(args, "fail");
|
||||
args_register(args, "fail");
|
||||
|
||||
if((arg = args_register_check(args)) != NULL){
|
||||
error(_("Unknown argument: "FG_BOLD"--%s"FG_RESET", run with "FG_BOLD"--help"FG_RESET" to list the avaliable arguments"), arg);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "sync <options>"));
|
||||
info(_("Listing options for the list command:"));
|
||||
printf(_(" "FG_BOLD"--fail"FG_RESET":\tquit on a single pool sync failure\n"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(config->pool_count == 0){
|
||||
error(_("There are no pools specified in the configuration"));
|
||||
goto end;
|
||||
}
|
||||
|
||||
sycned = lm_ctx_sync(ctx, true, callback_sync, NULL);
|
||||
fail = args_get_bool(args, "fail");
|
||||
synced = lm_ctx_sync(ctx, true, callback_sync, &fail);
|
||||
bar_free();
|
||||
|
||||
if(sycned < 0){
|
||||
if(synced < 0 && !fail){
|
||||
error(_("Failed to sync pools: %s"), lm_strerror());
|
||||
goto end;
|
||||
}
|
||||
|
||||
info(_("Synced "FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET" pools"), sycned, config->pool_count);
|
||||
else if(synced < 0 && fail)
|
||||
goto end;
|
||||
|
||||
info(_("Synced "FG_BOLD"%d"FG_RESET"/"FG_BOLD"%d"FG_RESET" pools"), synced, config->pool_count);
|
||||
ret = true;
|
||||
|
||||
end:
|
||||
|
@ -19,6 +19,7 @@ bool cmd_update(lm_ctx_t *ctx, config_t *config, args_t *args){
|
||||
}
|
||||
|
||||
if(args_get_bool(args, "help")){
|
||||
info(_("Usage: " FG_BOLD "update <options>"));
|
||||
info(_("Listing options for the update command:"));
|
||||
printf(_(" "FG_BOLD"--yes"FG_RESET":\tdon't ask for confirmation\n"));
|
||||
return true;
|
||||
|
@ -198,7 +198,8 @@ help:
|
||||
|
||||
printf(
|
||||
_(" " FG_BOLD "--config" FG_RESET ":\t specify the configuration file (default is /etc/matt/config.ini)\n"));
|
||||
printf(_(" " FG_BOLD "--root" FG_RESET ":\t specify a custom root directory (default is /)\n\n"));
|
||||
printf(_(" " FG_BOLD "--root" FG_RESET ":\t specify a custom root directory (default is /)\n"));
|
||||
printf(_(" " FG_BOLD "--help" FG_RESET ":\t list avaliable options/commands\n\n"));
|
||||
|
||||
info(_("Licensed under GPLv3, see https://www.gnu.org/licenses/ for more information"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user