mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Feature: Editing failure stops all editing of multiple tasks
- Thanks to Daniel Shahaf.
This commit is contained in:
parent
f1251303de
commit
9360bd577f
12 changed files with 33 additions and 16 deletions
|
@ -84,6 +84,8 @@
|
||||||
- "import" can now import JSON arrays, the new default "export" output.
|
- "import" can now import JSON arrays, the new default "export" output.
|
||||||
- The '_tags' helper command now includes virtual tags (thanks to Daniel
|
- The '_tags' helper command now includes virtual tags (thanks to Daniel
|
||||||
Shahaf).
|
Shahaf).
|
||||||
|
-When multiple tasks are 'edit'ed, a failure causes the editing to stop (thanks
|
||||||
|
to Daniel Shahaf).
|
||||||
|
|
||||||
------ current release ---------------------------
|
------ current release ---------------------------
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <cstring>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
|
@ -68,8 +69,13 @@ int CmdEdit::execute (std::string& output)
|
||||||
|
|
||||||
// Find number of matching tasks.
|
// Find number of matching tasks.
|
||||||
for (auto& task : filtered)
|
for (auto& task : filtered)
|
||||||
if (editFile (task))
|
{
|
||||||
|
CmdEdit::editResult result = editFile (task);
|
||||||
|
if (result == CmdEdit::editResult::error)
|
||||||
|
break;
|
||||||
|
else if (result == CmdEdit::editResult::changes)
|
||||||
context.tdb2.modify (task);
|
context.tdb2.modify (task);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -730,7 +736,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool CmdEdit::editFile (Task& task)
|
CmdEdit::editResult CmdEdit::editFile (Task& task)
|
||||||
{
|
{
|
||||||
// Check for file permissions.
|
// Check for file permissions.
|
||||||
Directory location (context.config.get ("data.location"));
|
Directory location (context.config.get ("data.location"));
|
||||||
|
@ -775,10 +781,16 @@ ARE_THESE_REALLY_HARMFUL:
|
||||||
|
|
||||||
// Launch the editor.
|
// Launch the editor.
|
||||||
std::cout << format (STRING_EDIT_LAUNCHING, editor) << "\n";
|
std::cout << format (STRING_EDIT_LAUNCHING, editor) << "\n";
|
||||||
if (-1 == system (editor.c_str ()))
|
int exitcode = system (editor.c_str ());
|
||||||
std::cout << STRING_EDIT_NO_EDITS << "\n";
|
if (0 == exitcode)
|
||||||
else
|
|
||||||
std::cout << STRING_EDIT_COMPLETE << "\n";
|
std::cout << STRING_EDIT_COMPLETE << "\n";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << format (STRING_EDIT_FAILED, exitcode) << "\n";
|
||||||
|
if (-1 == exitcode)
|
||||||
|
std::cout << std::strerror (errno) << "\n";
|
||||||
|
return CmdEdit::editResult::error;
|
||||||
|
}
|
||||||
|
|
||||||
// Slurp file.
|
// Slurp file.
|
||||||
std::string after;
|
std::string after;
|
||||||
|
@ -826,7 +838,9 @@ ARE_THESE_REALLY_HARMFUL:
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
File::remove (file.str ());
|
File::remove (file.str ());
|
||||||
ignored = chdir (current_dir.c_str ());
|
ignored = chdir (current_dir.c_str ());
|
||||||
return changes;
|
return changes
|
||||||
|
? CmdEdit::editResult::changes
|
||||||
|
: CmdEdit::editResult::nochanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -45,7 +45,8 @@ private:
|
||||||
std::string formatDuration (Task&, const std::string&);
|
std::string formatDuration (Task&, const std::string&);
|
||||||
std::string formatTask (Task, const std::string&);
|
std::string formatTask (Task, const std::string&);
|
||||||
void parseTask (Task&, const std::string&, const std::string&);
|
void parseTask (Task&, const std::string&, const std::string&);
|
||||||
bool editFile (Task&);
|
enum class editResult { error, changes, nochanges };
|
||||||
|
editResult editFile (Task&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -667,7 +667,7 @@
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
#define STRING_EDIT_NO_CHANGES "Keine Änderungen entdeckt."
|
#define STRING_EDIT_NO_CHANGES "Keine Änderungen entdeckt."
|
||||||
#define STRING_EDIT_NO_EDITS "Keine Änderungen ausgeführt."
|
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
|
||||||
#define STRING_EDIT_COMPLETE "Bearbeitung abgeschlossen."
|
#define STRING_EDIT_COMPLETE "Bearbeitung abgeschlossen."
|
||||||
#define STRING_EDIT_LAUNCHING "Starte jetzt '{1}'..."
|
#define STRING_EDIT_LAUNCHING "Starte jetzt '{1}'..."
|
||||||
#define STRING_EDIT_CHANGES "Änderungen entdeckt."
|
#define STRING_EDIT_CHANGES "Änderungen entdeckt."
|
||||||
|
|
|
@ -667,7 +667,7 @@
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
#define STRING_EDIT_NO_CHANGES "No edits were detected."
|
#define STRING_EDIT_NO_CHANGES "No edits were detected."
|
||||||
#define STRING_EDIT_NO_EDITS "No editing performed."
|
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
|
||||||
#define STRING_EDIT_COMPLETE "Editing complete."
|
#define STRING_EDIT_COMPLETE "Editing complete."
|
||||||
#define STRING_EDIT_LAUNCHING "Launching '{1}' now..."
|
#define STRING_EDIT_LAUNCHING "Launching '{1}' now..."
|
||||||
#define STRING_EDIT_CHANGES "Edits were detected."
|
#define STRING_EDIT_CHANGES "Edits were detected."
|
||||||
|
|
|
@ -667,7 +667,7 @@
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
#define STRING_EDIT_NO_CHANGES "Ne detektis nenian redakton."
|
#define STRING_EDIT_NO_CHANGES "Ne detektis nenian redakton."
|
||||||
#define STRING_EDIT_NO_EDITS "Ne redaktis nenion."
|
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
|
||||||
#define STRING_EDIT_COMPLETE "Redaktis komplete."
|
#define STRING_EDIT_COMPLETE "Redaktis komplete."
|
||||||
#define STRING_EDIT_LAUNCHING "Lanĉanta nun '{1}'..."
|
#define STRING_EDIT_LAUNCHING "Lanĉanta nun '{1}'..."
|
||||||
#define STRING_EDIT_CHANGES "Detektis redaktojn."
|
#define STRING_EDIT_CHANGES "Detektis redaktojn."
|
||||||
|
|
|
@ -679,7 +679,7 @@
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
#define STRING_EDIT_NO_CHANGES "No se detectaron modificaciones."
|
#define STRING_EDIT_NO_CHANGES "No se detectaron modificaciones."
|
||||||
#define STRING_EDIT_NO_EDITS "No se realizó edición."
|
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
|
||||||
#define STRING_EDIT_COMPLETE "Edición completada."
|
#define STRING_EDIT_COMPLETE "Edición completada."
|
||||||
#define STRING_EDIT_LAUNCHING "Lanzando '{1}' ahora..."
|
#define STRING_EDIT_LAUNCHING "Lanzando '{1}' ahora..."
|
||||||
#define STRING_EDIT_CHANGES "Se detectaron modificaciones."
|
#define STRING_EDIT_CHANGES "Se detectaron modificaciones."
|
||||||
|
|
|
@ -667,7 +667,7 @@
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
#define STRING_EDIT_NO_CHANGES "Aucunes modifications détectées."
|
#define STRING_EDIT_NO_CHANGES "Aucunes modifications détectées."
|
||||||
#define STRING_EDIT_NO_EDITS "Aucune modification appliquée."
|
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
|
||||||
#define STRING_EDIT_COMPLETE "Édition terminée."
|
#define STRING_EDIT_COMPLETE "Édition terminée."
|
||||||
#define STRING_EDIT_LAUNCHING "Lancement de '{1}' maintenant..."
|
#define STRING_EDIT_LAUNCHING "Lancement de '{1}' maintenant..."
|
||||||
#define STRING_EDIT_CHANGES "Des modifications ont été détectées."
|
#define STRING_EDIT_CHANGES "Des modifications ont été détectées."
|
||||||
|
|
|
@ -666,7 +666,7 @@
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
#define STRING_EDIT_NO_CHANGES "Nessuna modifica riscontrata."
|
#define STRING_EDIT_NO_CHANGES "Nessuna modifica riscontrata."
|
||||||
#define STRING_EDIT_NO_EDITS "Nessuna modifica effettuata."
|
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
|
||||||
#define STRING_EDIT_COMPLETE "Modifica completa."
|
#define STRING_EDIT_COMPLETE "Modifica completa."
|
||||||
#define STRING_EDIT_LAUNCHING "Esecuzione di '{1}' ora..."
|
#define STRING_EDIT_LAUNCHING "Esecuzione di '{1}' ora..."
|
||||||
#define STRING_EDIT_CHANGES "Modifiche rilevate."
|
#define STRING_EDIT_CHANGES "Modifiche rilevate."
|
||||||
|
|
|
@ -667,7 +667,7 @@
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
#define STRING_EDIT_NO_CHANGES "No edits were detected."
|
#define STRING_EDIT_NO_CHANGES "No edits were detected."
|
||||||
#define STRING_EDIT_NO_EDITS "No editing performed."
|
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
|
||||||
#define STRING_EDIT_COMPLETE "Editing complete."
|
#define STRING_EDIT_COMPLETE "Editing complete."
|
||||||
#define STRING_EDIT_LAUNCHING "Launching '{1}' now..."
|
#define STRING_EDIT_LAUNCHING "Launching '{1}' now..."
|
||||||
#define STRING_EDIT_CHANGES "Edits were detected."
|
#define STRING_EDIT_CHANGES "Edits were detected."
|
||||||
|
|
|
@ -667,7 +667,7 @@
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
#define STRING_EDIT_NO_CHANGES "Nie znaleziono żadnych edycji."
|
#define STRING_EDIT_NO_CHANGES "Nie znaleziono żadnych edycji."
|
||||||
#define STRING_EDIT_NO_EDITS "Nie wykonano żadnych edycji"
|
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
|
||||||
#define STRING_EDIT_COMPLETE "Edycja zakończona."
|
#define STRING_EDIT_COMPLETE "Edycja zakończona."
|
||||||
#define STRING_EDIT_LAUNCHING "Uruchamianie '{1}'..."
|
#define STRING_EDIT_LAUNCHING "Uruchamianie '{1}'..."
|
||||||
#define STRING_EDIT_CHANGES "Zmiany wykryte."
|
#define STRING_EDIT_CHANGES "Zmiany wykryte."
|
||||||
|
|
|
@ -667,7 +667,7 @@
|
||||||
|
|
||||||
// edit
|
// edit
|
||||||
#define STRING_EDIT_NO_CHANGES "Não foram detetadas alterações."
|
#define STRING_EDIT_NO_CHANGES "Não foram detetadas alterações."
|
||||||
#define STRING_EDIT_NO_EDITS "Nada editado."
|
#define STRING_EDIT_FAILED "Editing failed with exit code {1}."
|
||||||
#define STRING_EDIT_COMPLETE "Edição concluída."
|
#define STRING_EDIT_COMPLETE "Edição concluída."
|
||||||
#define STRING_EDIT_LAUNCHING "A iniciar '{1}' ..."
|
#define STRING_EDIT_LAUNCHING "A iniciar '{1}' ..."
|
||||||
#define STRING_EDIT_CHANGES "Alterações detetadas."
|
#define STRING_EDIT_CHANGES "Alterações detetadas."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue