MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / deleteNote

Method deleteNote

cmdtools/cmdlinetool.cpp:151–179  ·  view source on GitHub ↗

Delete a note via the command line

Source from the content-addressed store, hash-verified

149
150// Delete a note via the command line
151int CmdLineTool::deleteNote(StartupConfig config) {
152 bool useCrossMemory = true;
153
154 if (config.delNote->verifyDelete) {
155 std::string verify;
156 std::cout << QString(tr("Type DELETE to verify: ")).toStdString();
157 std::cin >> verify;
158 QString qVerify = QString::fromStdString(verify);
159 if (qVerify.toLower() != "delete")
160 return 16;
161 }
162
163 // Look to see if another NixNote is running. If so, then we
164 // expect a response if the note was delete. Otherwise, we
165 // do it ourself.
166 global.sharedMemory->unlock();
167 global.sharedMemory->detach();
168 if (!global.sharedMemory->attach()) {
169 useCrossMemory = false;
170 }
171 if (useCrossMemory) {
172 global.sharedMemory->write("DELETE_NOTE:" + QString::number(config.delNote->lid));
173 } else {
174 global.db = new DatabaseConnection("nixnote"); // Startup the database
175 NoteTable noteTable(global.db);
176 noteTable.deleteNote(config.delNote->lid,true);
177 }
178 return 0;
179}
180
181
182// Query notes via the command line

Callers 2

extractMethod · 0.45
runMethod · 0.45

Calls 5

detachMethod · 0.80
attachMethod · 0.80
QStringClass · 0.50
unlockMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected