Mi: mi backend + mi for command version
[lttng-tools.git] / src / bin / lttng / commands / destroy.c
index 7b7ea0e8028cec3f15e160f4f2c374079982fc5f..26548b9e153521f1b74b2d5c10d44968e7179744 100644 (file)
@@ -49,11 +49,12 @@ static struct poptOption long_options[] = {
  */
 static void usage(FILE *ofp)
 {
-       fprintf(ofp, "usage: lttng destroy [options] [NAME]\n");
+       fprintf(ofp, "usage: lttng destroy [NAME] [OPTIONS]\n");
        fprintf(ofp, "\n");
        fprintf(ofp, "Where NAME is an optional session name. If not specified, lttng will\n");
        fprintf(ofp, "get it from the configuration directory (.lttng).\n");
        fprintf(ofp, "\n");
+       fprintf(ofp, "Options:\n");
        fprintf(ofp, "  -h, --help           Show this help\n");
        fprintf(ofp, "  -a, --all            Destroy all sessions\n");
        fprintf(ofp, "      --list-options   Simple listing of options\n");
@@ -73,10 +74,11 @@ static int destroy_session(const char *session_name)
        ret = lttng_destroy_session(session_name);
        if (ret < 0) {
                switch (-ret) {
-               case LTTCOMM_SESS_NOT_FOUND:
+               case LTTNG_ERR_SESS_NOT_FOUND:
                        WARN("Session name %s not found", session_name);
                        break;
                default:
+                       ERR("%s", lttng_strerror(ret));
                        break;
                }
                goto error;
@@ -102,7 +104,11 @@ static int destroy_all_sessions()
        count = lttng_list_sessions(&sessions);
        if (count == 0) {
                MSG("No session found, nothing to do.");
+       } else if (count < 0) {
+               ERR("%s", lttng_strerror(ret));
+               goto error;
        }
+
        for (i = 0; i < count; i++) {
                ret = destroy_session(sessions[i].name);
                if (ret < 0) {
@@ -113,21 +119,6 @@ error:
        return ret;
 }
 
-/*
- * get_default_session_name
- *
- * Returns the default sessions name, if any
- */
-static int get_default_session_name(char **name)
-{
-       char *session_name = get_session_name();
-       if (session_name == NULL) {
-               return CMD_ERROR;
-       }
-       *name = session_name;
-       return CMD_SUCCESS;
-}
-
 /*
  * The 'destroy <options>' first level command
  */
@@ -157,6 +148,13 @@ int cmd_destroy(int argc, const char **argv)
                goto end;
        }
 
+       /* TODO: mi support */
+       if (lttng_opt_mi) {
+               ret = -LTTNG_ERR_MI_NOT_IMPLEMENTED;
+               ERR("mi option not supported");
+               goto end;
+       }
+
        /* Ignore session name in case all sessions are to be destroyed */
        if (opt_destroy_all) {
                ret = destroy_all_sessions();
This page took 0.025947 seconds and 5 git commands to generate.