* mu-cmd*: cleanup command handling

This commit is contained in:
Dirk-Jan C. Binnema
2011-08-30 21:57:59 +03:00
parent b375199bfa
commit 0861319091
5 changed files with 206 additions and 132 deletions

View File

@ -36,7 +36,7 @@ print_header (MuConfigFormat format)
{ {
switch (format) { switch (format) {
case MU_CONFIG_FORMAT_BBDB: case MU_CONFIG_FORMAT_BBDB:
g_print (";; -*-coding: utf-8-emacs;-*-\n" g_print (";; -*-coding: utf-8-emacs;-*-\n"
";;; file-version: 6\n"); ";;; file-version: 6\n");
break; break;
case MU_CONFIG_FORMAT_MUTT_AB: case MU_CONFIG_FORMAT_MUTT_AB:
@ -56,7 +56,7 @@ each_contact_bbdb (const char *email, const char *name, time_t tstamp)
lname = mu_str_guess_last_name (name); lname = mu_str_guess_last_name (name);
now = mu_date_str ("%Y-%m-%d", time(NULL)); now = mu_date_str ("%Y-%m-%d", time(NULL));
timestamp = mu_date_str ("%Y-%m-%d", tstamp); timestamp = mu_date_str ("%Y-%m-%d", tstamp);
g_print ("[\"%s\" \"%s\" nil nil nil nil (\"%s\") " g_print ("[\"%s\" \"%s\" nil nil nil nil (\"%s\") "
"((creation-date . \"%s\") (time-stamp . \"%s\")) nil]\n", "((creation-date . \"%s\") (time-stamp . \"%s\")) nil]\n",
fname, lname, email, now, timestamp); fname, lname, email, now, timestamp);
@ -64,7 +64,7 @@ each_contact_bbdb (const char *email, const char *name, time_t tstamp)
g_free (now); g_free (now);
g_free (timestamp); g_free (timestamp);
g_free (fname); g_free (fname);
g_free (lname); g_free (lname);
} }
@ -78,7 +78,7 @@ each_contact_mutt_alias (const char *email, const char *name)
nick = mu_str_guess_nick (name); nick = mu_str_guess_nick (name);
mu_util_print_encoded ("alias %s %s <%s>\n", mu_util_print_encoded ("alias %s %s <%s>\n",
nick, name, email); nick, name, email);
g_free (nick); g_free (nick);
} }
@ -155,7 +155,7 @@ each_contact (const char *email, const char *name, time_t tstamp,
break; break;
case MU_CONFIG_FORMAT_BBDB: case MU_CONFIG_FORMAT_BBDB:
each_contact_bbdb (email, name, tstamp); each_contact_bbdb (email, name, tstamp);
break; break;
case MU_CONFIG_FORMAT_CSV: case MU_CONFIG_FORMAT_CSV:
mu_util_print_encoded ("%s,%s\n", name ? name : "", email); mu_util_print_encoded ("%s,%s\n", name ? name : "", email);
break; break;
@ -173,7 +173,7 @@ run_cmd_cfind (const char* pattern, MuConfigFormat format,
MuContacts *contacts; MuContacts *contacts;
size_t num; size_t num;
ECData ecdata = {format, color}; ECData ecdata = {format, color};
contacts = mu_contacts_new (mu_runtime_path(MU_RUNTIME_PATH_CONTACTS)); contacts = mu_contacts_new (mu_runtime_path(MU_RUNTIME_PATH_CONTACTS));
if (!contacts) { if (!contacts) {
g_warning ("could not retrieve contacts"); g_warning ("could not retrieve contacts");

View File

@ -61,7 +61,7 @@ static void
upgrade_warning (void) upgrade_warning (void)
{ {
g_warning ("the database needs to be updated to version %s\n", g_warning ("the database needs to be updated to version %s\n",
MU_XAPIAN_DB_VERSION); MU_STORE_SCHEMA_VERSION);
g_message ("please run 'mu index --rebuild' (see the man page)"); g_message ("please run 'mu index --rebuild' (see the man page)");
} }
@ -227,8 +227,20 @@ exec_cmd_on_query (MuQuery *xapian, const gchar *query, MuConfig *opts,
for (rv = TRUE, *count = 0; !mu_msg_iter_is_done (iter); for (rv = TRUE, *count = 0; !mu_msg_iter_is_done (iter);
mu_msg_iter_next(iter)) { mu_msg_iter_next(iter)) {
rv = exec_cmd (mu_msg_get_path (mu_msg_iter_get_msg (iter, NULL)), const char *path;
opts->exec); MuMsg *msg;
msg = mu_msg_iter_get_msg_floating (iter);
if (!msg)
continue;
path = mu_msg_get_path (msg);
if (!msg) {
g_warning ("cannot get path for msg");
continue;
}
rv = exec_cmd (path, opts->exec);
if (rv) if (rv)
++*count; ++*count;
} }
@ -346,15 +358,15 @@ get_query (MuConfig *opts)
} }
static gboolean static gboolean
db_is_ready (const char *xpath) db_is_ready (MuStore *store)
{ {
if (mu_store_database_is_empty (xpath)) { if (mu_store_count (store) == 0) {
g_warning ("database is empty; use 'mu index' to " g_warning ("database is empty; use 'mu index' to "
"add messages"); "add messages");
return FALSE; return FALSE;
} }
if (mu_store_database_needs_upgrade (xpath)) { if (mu_store_needs_upgrade (store)) {
upgrade_warning (); upgrade_warning ();
return FALSE; return FALSE;
} }
@ -363,20 +375,18 @@ db_is_ready (const char *xpath)
} }
static MuQuery* static MuQuery*
get_query_obj (void) get_query_obj (MuStore *store)
{ {
GError *err; GError *err;
const char* xpath;
MuQuery *mquery; MuQuery *mquery;
xpath = mu_runtime_path (MU_RUNTIME_PATH_XAPIANDB); if (!db_is_ready(store)) {
if (!db_is_ready(xpath)) { g_warning ("database is not ready");
g_warning ("database '%s' is not ready", xpath);
return NULL; return NULL;
} }
err = NULL; err = NULL;
mquery = mu_query_new (xpath, &err); mquery = mu_query_new (store, &err);
if (!mquery) { if (!mquery) {
g_warning ("error: %s", err->message); g_warning ("error: %s", err->message);
g_error_free (err); g_error_free (err);
@ -445,8 +455,7 @@ static gboolean
output_links (MuMsgIter *iter, const char* linksdir, output_links (MuMsgIter *iter, const char* linksdir,
gboolean clearlinks, size_t *count) gboolean clearlinks, size_t *count)
{ {
size_t mycount; size_t okcount, errcount;
gboolean errseen;
MuMsgIter *myiter; MuMsgIter *myiter;
g_return_val_if_fail (iter, FALSE); g_return_val_if_fail (iter, FALSE);
@ -456,31 +465,26 @@ output_links (MuMsgIter *iter, const char* linksdir,
if (!create_linksdir_maybe (linksdir, clearlinks)) if (!create_linksdir_maybe (linksdir, clearlinks))
return FALSE; return FALSE;
for (myiter = iter, errseen = FALSE, mycount = 0; !mu_msg_iter_is_done (myiter); for (myiter = iter, errcount = okcount = 0; !mu_msg_iter_is_done (myiter);
mu_msg_iter_next (myiter)) { mu_msg_iter_next (myiter)) {
MuMsg *msg;
const char* path; const char* path;
MuMsg *msg;
msg = mu_msg_iter_get_msg (iter, NULL); /* don't unref */ msg = mu_msg_iter_get_msg_floating (iter);
if (!msg) if (!msg)
return FALSE;
path = mu_msg_get_path (msg);
if (!access (path, R_OK)) /* only link to readable */
continue; continue;
if (!link_message (path, linksdir)) path = mu_msg_get_path (msg);
errseen = TRUE; if (access (path, R_OK) == 0) /* only link to readable */
else link_message (path, linksdir) ? ++okcount : ++errcount;
++mycount;
} }
if (errseen) if (errcount > 0)
g_warning ("error linking some of the messages"); g_warning ("error linking some of the messages");
if (count) if (count)
*count = mycount; *count = okcount;
return TRUE; return TRUE;
} }
@ -594,8 +598,8 @@ thread_indent (MuMsgIter *iter)
ti = mu_msg_iter_get_thread_info (iter); ti = mu_msg_iter_get_thread_info (iter);
if (!ti) { if (!ti) {
g_warning ("cannot get thread-info for %s", g_warning ("cannot get thread-info for message %u",
mu_msg_get_subject(mu_msg_iter_get_msg(iter, NULL))); mu_msg_iter_get_docid (iter));
return; return;
} }
@ -665,15 +669,12 @@ output_plain (MuMsgIter *iter, const char *fields, gboolean summary,
for (myiter = iter, mycount = 0; !mu_msg_iter_is_done (myiter); for (myiter = iter, mycount = 0; !mu_msg_iter_is_done (myiter);
mu_msg_iter_next (myiter)) { mu_msg_iter_next (myiter)) {
size_t len; size_t len;
MuMsg *msg; MuMsg *msg;
msg = mu_msg_iter_get_msg (iter, NULL); /* don't unref */ msg = mu_msg_iter_get_msg_floating (iter); /* don't unref */
if (!msg) { if (!msg)
g_warning ("can't get message");
continue; continue;
}
/* only return messages if they're actually /* only return messages if they're actually
* readable (ie, live also outside the database) */ * readable (ie, live also outside the database) */
@ -732,7 +733,7 @@ output_sexp (MuMsgIter *iter, gboolean threads,
char *sexp; char *sexp;
const MuMsgIterThreadInfo *ti; const MuMsgIterThreadInfo *ti;
msg = mu_msg_iter_get_msg (iter, NULL); /* don't unref */ msg = mu_msg_iter_get_msg_floating (iter);
if (!msg) if (!msg)
return FALSE; return FALSE;
@ -790,8 +791,11 @@ output_xml (MuMsgIter *iter, gboolean include_unreadable, size_t *count)
for (myiter = iter, mycount = 0; !mu_msg_iter_is_done (myiter); for (myiter = iter, mycount = 0; !mu_msg_iter_is_done (myiter);
mu_msg_iter_next (myiter)) { mu_msg_iter_next (myiter)) {
GError *err;
MuMsg *msg; MuMsg *msg;
msg = mu_msg_iter_get_msg (iter, NULL); /* don't unref */
err = NULL;
msg = mu_msg_iter_get_msg_floating (iter); /* don't unref */
if (!msg) if (!msg)
return FALSE; return FALSE;
@ -801,7 +805,6 @@ output_xml (MuMsgIter *iter, gboolean include_unreadable, size_t *count)
continue; continue;
output_xml_msg (msg); output_xml_msg (msg);
++mycount; ++mycount;
} }
g_print ("</messages>\n"); g_print ("</messages>\n");
@ -814,7 +817,7 @@ output_xml (MuMsgIter *iter, gboolean include_unreadable, size_t *count)
MuError MuError
mu_cmd_find (MuConfig *opts) mu_cmd_find (MuStore *store, MuConfig *opts)
{ {
MuQuery *xapian; MuQuery *xapian;
gboolean rv; gboolean rv;
@ -828,7 +831,7 @@ mu_cmd_find (MuConfig *opts)
if (!query_params_valid (opts) || !format_params_valid(opts)) if (!query_params_valid (opts) || !format_params_valid(opts))
return MU_ERROR_IN_PARAMETERS; return MU_ERROR_IN_PARAMETERS;
xapian = get_query_obj(); xapian = get_query_obj(store);
query = get_query (opts); query = get_query (opts);
if (!xapian ||!query) if (!xapian ||!query)

View File

@ -43,7 +43,7 @@ static void
update_warning (void) update_warning (void)
{ {
g_warning ("note: the database needs to be upgraded to version %s", g_warning ("note: the database needs to be upgraded to version %s",
MU_XAPIAN_DB_VERSION); MU_STORE_SCHEMA_VERSION);
g_warning ("please run 'mu index --rebuild' (see the manpage)"); g_warning ("please run 'mu index --rebuild' (see the manpage)");
} }
@ -195,33 +195,28 @@ index_msg_cb (MuIndexStats* stats, void *user_data)
static gboolean static gboolean
database_version_check_and_update (MuConfig *opts) database_version_check_and_update (MuStore *store, MuConfig *opts)
{ {
const gchar *xpath, *ccache; if (mu_store_count (store) == 0)
xpath = mu_runtime_path (MU_RUNTIME_PATH_XAPIANDB);
ccache = mu_runtime_path (MU_RUNTIME_PATH_CONTACTS);
if (mu_store_database_is_empty (xpath))
return TRUE; return TRUE;
/* when rebuilding, we empty the database before doing /* when rebuilding, we empty the database before doing
* anything */ * anything */
if (opts->rebuild) { if (opts->rebuild) {
opts->reindex = TRUE; opts->reindex = TRUE;
g_message ("clearing database [%s]", xpath); g_message ("clearing database");
g_message ("clearing contacts-cache [%s]", ccache); g_message ("clearing contacts-cache");
return mu_store_database_clear (xpath, ccache); return mu_store_clear (store);
} }
if (!mu_store_database_needs_upgrade (xpath)) if (!mu_store_needs_upgrade (store))
return TRUE; /* ok, nothing to do */ return TRUE; /* ok, nothing to do */
/* ok, database is not up to date */ /* ok, database is not up to date */
if (opts->autoupgrade) { if (opts->autoupgrade) {
opts->reindex = TRUE; opts->reindex = TRUE;
g_message ("auto-upgrade: clearing old database and cache"); g_message ("auto-upgrade: clearing old database and cache");
return mu_store_database_clear (xpath, ccache); return mu_store_clear (store);
} }
update_warning (); update_warning ();
@ -368,7 +363,7 @@ handle_index_error_and_free (GError *err)
} }
static MuIndex* static MuIndex*
init_mu_index (MuConfig *opts, MuError *code) init_mu_index (MuStore *store, MuConfig *opts, MuError *code)
{ {
MuIndex *midx; MuIndex *midx;
GError *err; GError *err;
@ -378,15 +373,13 @@ init_mu_index (MuConfig *opts, MuError *code)
return NULL; return NULL;
} }
if (!database_version_check_and_update(opts)) { if (!database_version_check_and_update(store, opts)) {
*code = MU_ERROR_XAPIAN_NOT_UP_TO_DATE; *code = MU_ERROR_XAPIAN_NOT_UP_TO_DATE;
return NULL; return NULL;
} }
err = NULL; err = NULL;
midx = mu_index_new (mu_runtime_path (MU_RUNTIME_PATH_XAPIANDB), midx = mu_index_new (store, &err);
mu_runtime_path (MU_RUNTIME_PATH_CONTACTS),
&err);
if (!midx) { if (!midx) {
*code = handle_index_error_and_free (err); *code = handle_index_error_and_free (err);
return NULL; return NULL;
@ -400,7 +393,7 @@ init_mu_index (MuConfig *opts, MuError *code)
static MuError static MuError
cmd_index_or_cleanup (MuConfig *opts) cmd_index_or_cleanup (MuStore *store, MuConfig *opts)
{ {
MuIndex *midx; MuIndex *midx;
MuIndexStats stats; MuIndexStats stats;
@ -408,7 +401,7 @@ cmd_index_or_cleanup (MuConfig *opts)
MuError code; MuError code;
/* create, and do error handling if needed */ /* create, and do error handling if needed */
midx = init_mu_index (opts, &code); midx = init_mu_index (store, opts, &code);
if (!midx) if (!midx)
return code; return code;
@ -442,23 +435,23 @@ cmd_index_or_cleanup (MuConfig *opts)
MuError MuError
mu_cmd_index (MuConfig *opts) mu_cmd_index (MuStore *store, MuConfig *opts)
{ {
g_return_val_if_fail (opts, FALSE); g_return_val_if_fail (opts, FALSE);
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_INDEX, g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_INDEX,
FALSE); FALSE);
return cmd_index_or_cleanup (opts); return cmd_index_or_cleanup (store, opts);
} }
MuError MuError
mu_cmd_cleanup (MuConfig *opts) mu_cmd_cleanup (MuStore *store, MuConfig *opts)
{ {
g_return_val_if_fail (opts, MU_ERROR_INTERNAL); g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
g_return_val_if_fail (opts->cmd != MU_CONFIG_CMD_CLEANUP, g_return_val_if_fail (opts->cmd != MU_CONFIG_CMD_CLEANUP,
MU_ERROR_INTERNAL); MU_ERROR_INTERNAL);
return cmd_index_or_cleanup (opts); return cmd_index_or_cleanup (store, opts);
} }

View File

@ -395,36 +395,15 @@ check_file_okay (const char *path, gboolean cmd_add)
} }
static MuStore*
get_store (void)
{
MuStore *store;
GError *err;
err = NULL;
store = mu_store_new_writable
(mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB),
mu_runtime_path(MU_RUNTIME_PATH_CONTACTS),
&err);
if (!store) {
if (err) {
g_warning ("store error: %s", err->message);
g_error_free (err);
} else
g_warning ("failed to create store object");
}
return store;
}
MuError MuError
mu_cmd_add (MuConfig *opts) mu_cmd_add (MuStore *store, MuConfig *opts)
{ {
MuStore *store;
gboolean allok; gboolean allok;
int i; int i;
g_return_val_if_fail (store, MU_ERROR_INTERNAL);
g_return_val_if_fail (opts, MU_ERROR_INTERNAL); g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_ADD, g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_ADD,
MU_ERROR_INTERNAL); MU_ERROR_INTERNAL);
@ -435,10 +414,6 @@ mu_cmd_add (MuConfig *opts)
return MU_ERROR_IN_PARAMETERS; return MU_ERROR_IN_PARAMETERS;
} }
store = get_store ();
if (!store)
return MU_ERROR_INTERNAL;
for (i = 1, allok = TRUE; opts->params[i]; ++i) { for (i = 1, allok = TRUE; opts->params[i]; ++i) {
const char* src; const char* src;
@ -455,16 +430,13 @@ mu_cmd_add (MuConfig *opts)
} }
} }
mu_store_destroy (store);
return allok ? MU_OK : MU_ERROR; return allok ? MU_OK : MU_ERROR;
} }
MuError MuError
mu_cmd_remove (MuConfig *opts) mu_cmd_remove (MuStore *store, MuConfig *opts)
{ {
MuStore *store;
gboolean allok; gboolean allok;
int i; int i;
@ -478,10 +450,6 @@ mu_cmd_remove (MuConfig *opts)
return MU_ERROR_IN_PARAMETERS; return MU_ERROR_IN_PARAMETERS;
} }
store = get_store ();
if (!store)
return MU_ERROR_INTERNAL;
for (i = 1, allok = TRUE; opts->params[i]; ++i) { for (i = 1, allok = TRUE; opts->params[i]; ++i) {
const char* src; const char* src;
@ -498,10 +466,107 @@ mu_cmd_remove (MuConfig *opts)
} }
} }
mu_store_destroy (store);
return allok ? MU_OK : MU_ERROR; return allok ? MU_OK : MU_ERROR;
} }
static void
show_usage (gboolean noerror)
{
const char* usage=
"usage: mu command [options] [parameters]\n"
"where command is one of index, find, cfind, view, mkdir, cleanup, "
"extract, mv, add, remove or server\n\n"
"see the mu, mu-<command> or mu-easy manpages for "
"more information\n";
if (noerror)
g_print ("%s", usage);
else
g_printerr ("%s", usage);
}
static void
show_version (void)
{
g_print ("mu (mail indexer/searcher) version " VERSION "\n"
"Copyright (C) 2008-2011 Dirk-Jan C. Binnema (GPLv3+)\n");
}
typedef MuError (*store_func) (MuStore *, MuConfig *);
MuError
with_store (store_func func, MuConfig *opts, gboolean read_only)
{
MuStore *store;
GError *err;
err = NULL;
if (read_only)
store = mu_store_new_read_only
(mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB),
&err);
else
store = mu_store_new_writable
(mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB),
mu_runtime_path(MU_RUNTIME_PATH_CONTACTS),
&err);
if (!store) {
if (err) {
g_warning ("store error: %s", err->message);
g_error_free (err);
}
return MU_ERROR_XAPIAN;
} else {
MuError merr;
merr = func (store, opts);
mu_store_unref (store);
return merr;
}
}
MuError
mu_cmd_execute (MuConfig *opts)
{
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
if (opts->version) {
show_version ();
return MU_OK;
}
if (!opts->params||!opts->params[0]) {/* no command? */
show_version ();
show_usage (TRUE);
return MU_ERROR_IN_PARAMETERS;
}
switch (opts->cmd) {
case MU_CONFIG_CMD_CFIND: return mu_cmd_cfind (opts);
case MU_CONFIG_CMD_MKDIR: return mu_cmd_mkdir (opts);
case MU_CONFIG_CMD_MV: return mu_cmd_mv (opts);
case MU_CONFIG_CMD_VIEW: return mu_cmd_view (opts);
case MU_CONFIG_CMD_EXTRACT: return mu_cmd_extract (opts);
case MU_CONFIG_CMD_CLEANUP:
return with_store (mu_cmd_cleanup, opts, FALSE);
case MU_CONFIG_CMD_FIND:
return with_store (mu_cmd_find, opts, TRUE);
case MU_CONFIG_CMD_INDEX:
return with_store (mu_cmd_index, opts, FALSE);
case MU_CONFIG_CMD_ADD:
return with_store (mu_cmd_add, opts, FALSE);
case MU_CONFIG_CMD_REMOVE:
return with_store (mu_cmd_remove, opts, FALSE);
case MU_CONFIG_CMD_SERVER:
return with_store (mu_cmd_server, opts, FALSE);
default:
show_usage (FALSE);
return MU_ERROR_IN_PARAMETERS;
}
}

View File

@ -25,14 +25,15 @@
#include <glib.h> #include <glib.h>
#include <mu-config.h> #include <mu-config.h>
#include <mu-store.h>
G_BEGIN_DECLS G_BEGIN_DECLS
/** /**
* execute the 'mkdir' command * execute the 'mkdir' command
* *
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeded, * @return MU_OK (0) if the command succeeded,
* some error code otherwise * some error code otherwise
*/ */
@ -41,9 +42,9 @@ MuError mu_cmd_mkdir (MuConfig *opts);
/** /**
* execute the 'view' command * execute the 'view' command
* *
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeded, * @return MU_OK (0) if the command succeeded,
* some error code otherwise * some error code otherwise
*/ */
@ -55,11 +56,11 @@ MuError mu_cmd_view (MuConfig *opts);
* *
* @param store store object to use * @param store store object to use
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeded, * @return MU_OK (0) if the command succeeded,
* some error code otherwise * some error code otherwise
*/ */
MuError mu_cmd_index (MuConfig *opts); MuError mu_cmd_index (MuStore *store, MuConfig *opts);
/** /**
@ -67,29 +68,30 @@ MuError mu_cmd_index (MuConfig *opts);
* *
* @param store store object to use * @param store store object to use
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeds, * @return MU_OK (0) if the command succeeds,
* some error code otherwise * some error code otherwise
*/ */
MuError mu_cmd_cleanup (MuConfig *opts); MuError mu_cmd_cleanup (MuStore *store, MuConfig *opts);
/** /**
* execute the 'find' command * execute the 'find' command
* *
* @param store store object to use
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeds and * @return MU_OK (0) if the command succeeds and
* >MU_OK (0) results, MU_EXITCODE_NO_MATCHES if the command * >MU_OK (0) results, MU_EXITCODE_NO_MATCHES if the command
* succeeds but there no matches, some error code for all other errors * succeeds but there no matches, some error code for all other errors
*/ */
MuError mu_cmd_find (MuConfig *opts); MuError mu_cmd_find (MuStore *store, MuConfig *opts);
/** /**
* execute the 'extract' command * execute the 'extract' command
* *
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeds, * @return MU_OK (0) if the command succeeds,
* some error code otherwise * some error code otherwise
*/ */
@ -98,9 +100,9 @@ MuError mu_cmd_extract (MuConfig *opts);
/** /**
* execute the 'mv' command * execute the 'mv' command
* *
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeds, * @return MU_OK (0) if the command succeeds,
* some error code otherwise * some error code otherwise
*/ */
@ -108,9 +110,9 @@ MuError mu_cmd_mv (MuConfig *opts);
/** /**
* execute the cfind command * execute the cfind command
* *
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeds, * @return MU_OK (0) if the command succeeds,
* some error code otherwise * some error code otherwise
*/ */
@ -119,36 +121,47 @@ MuError mu_cmd_cfind (MuConfig *opts);
/** /**
* execute the add command * execute the add command
* *
* @param store store object to use
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeds, * @return MU_OK (0) if the command succeeds,
* some error code otherwise * some error code otherwise
*/ */
MuError mu_cmd_add (MuConfig *opts); MuError mu_cmd_add (MuStore *store, MuConfig *opts);
/** /**
* execute the remove command * execute the remove command
* *
* @param store store object to use
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeds, * @return MU_OK (0) if the command succeeds,
* some error code otherwise * some error code otherwise
*/ */
MuError mu_cmd_remove (MuConfig *opts); MuError mu_cmd_remove (MuStore *store, MuConfig *opts);
/** /**
* execute the server command * execute the server command
* * @param store store object to use
* @param opts configuration options * @param opts configuration options
* *
* @return MU_OK (0) if the command succeeds, * @return MU_OK (0) if the command succeeds,
* some error code otherwise * some error code otherwise
*/ */
MuError mu_cmd_server (MuConfig *opts); MuError mu_cmd_server (MuStore *store, MuConfig *opts);
/**
* execute some mu command, based on 'opts'
*
* @param opts configuration option
*
* @return MU_OK if all went wall, some error code otherwise
*/
MuError mu_cmd_execute (MuConfig *opts);
G_END_DECLS G_END_DECLS
#endif /*__MU_CMD_H__*/ #endif /*__MU_CMD_H__*/