]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- allow to change description of snapshots
authorArvin Schnell <aschnell@suse.de>
Thu, 10 Feb 2011 09:27:25 +0000 (10:27 +0100)
committerArvin Schnell <aschnell@suse.de>
Thu, 10 Feb 2011 09:27:25 +0000 (10:27 +0100)
snapper/Snapshot.cc
snapper/Snapshot.h
tools/snapper.cc

index dbff0cd883c1e1da97d66af5e3f608094d9261f9..62d055066f3b05174e4c137caf398cd3448d0c7a 100644 (file)
@@ -75,6 +75,14 @@ namespace snapper
     }
 
 
+    void
+    Snapshot::setDescription(const string& desc)
+    {
+       description = desc;
+       writeInfo();
+    }
+
+
     void
     Snapshots::read()
     {
@@ -246,7 +254,7 @@ namespace snapper
 
        setChildValue(node, "date", datetime(date, true, true));
 
-       if ((type == SINGLE || type == PRE) && !description.empty())
+       if (!description.empty())
            setChildValue(node, "description", description);
 
        if (type == POST)
index 599efca352751813f00e3b60b0dc0be133651d7a..a0e8208b2f49613d7995828ab4711883f52fccdb 100644 (file)
@@ -54,6 +54,7 @@ namespace snapper
 
        time_t getDate() const { return date; }
 
+       void setDescription(const string& description);
        string getDescription() const { return description; }
 
        unsigned int getPreNum() const { return pre_num; }
@@ -71,13 +72,14 @@ namespace snapper
 
        time_t date;
 
-       string description;     // empty for type=POST
+       string description;     // likely empty for type=POST
 
        unsigned int pre_num;   // valid only for type=POST
 
        bool writeInfo() const;
        bool createFilesystemSnapshot() const;
        bool deleteFilesystemSnapshot() const;
+
     };
 
 
index 324e9fabb80acb9c8d47322c0186dab835eab996..2ccc129d67dce59c5ad67eb7b3065fff24582baf 100644 (file)
@@ -170,6 +170,42 @@ command_create()
 }
 
 
+void
+help_modify()
+{
+    cout << _("  Modify snapshot:") << endl
+        << _("\tsnapper modify <number>") << endl
+        << endl
+        << _("    Options for 'modify' command:") << endl
+        << _("\t--description, -d <description>\tDescription for snapshot.") << endl
+        << endl;
+}
+
+
+void
+command_modify()
+{
+    const struct option options[] = {
+       { "description",        required_argument,      0,      'd' },
+       { 0, 0, 0, 0 }
+    };
+
+    GetOpts::parsed_opts opts = getopts.parse("modify", options);
+    if (getopts.numArgs() != 1)
+    {
+       cerr << _("Command 'modify' need one argument.") << endl;
+       exit(EXIT_FAILURE);
+    }
+
+    Snapshots::iterator snapshot = readNum(getopts.popArg());
+
+    GetOpts::parsed_opts::const_iterator it;
+
+    if ((it = opts.find("description")) != opts.end())
+       snapshot->setDescription(it->second);
+}
+
+
 void
 help_delete()
 {
@@ -345,6 +381,7 @@ command_help()
 
     help_list();
     help_create();
+    help_modify();
     help_delete();
     help_diff();
     help_rollback();
@@ -369,6 +406,7 @@ main(int argc, char** argv)
 
     cmds["list"] = command_list;
     cmds["create"] = command_create;
+    cmds["modify"] = command_modify;
     cmds["delete"] = command_delete;
     cmds["diff"] = command_diff;
     cmds["rollback"] = command_rollback;