aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2016-12-31 15:57:36 +0100
committerache <ache@ache.one>2016-12-31 15:57:36 +0100
commitf1c6891475f385c3c09c4f08240be9f764eca2f7 (patch)
treeab586239b00b91b45c5e6e41662d91883eb6b822
parentCorrection non de variable (diff)
Add uncheck option
-rwxr-xr-x[-rw-r--r--]todo.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/todo.cpp b/todo.cpp
index a62de93..b49cfc0 100644..100755
--- a/todo.cpp
+++ b/todo.cpp
@@ -78,6 +78,8 @@ int main(int argc, char *argv[]) {
action = 2;
}else if ( !strcmp( argv[1], "check") ) {
action = 3;
+ }else if ( !strcmp( argv[1], "uncheck") ) {
+ action = 9;
}else if ( !strcmp( argv[1], "set") ) {
if( argc > 2 && argv[2][0] >= '0' && argv[2][0] <= '9' )
action = 4;
@@ -98,7 +100,7 @@ int main(int argc, char *argv[]) {
else
action = 0;
if( action == -1 ) {
- cout << "Usage : todo [show,add,remove,check,set,clean/clear,checked,unchecked/todo]" << endl;
+ cout << "Usage : todo [show,add,remove,check/uncheck,set,clean/clear,checked,unchecked/todo]" << endl;
} else {
ifstream file(".todo.txt", ios::in);
@@ -191,6 +193,16 @@ int main(int argc, char *argv[]) {
if( !it->etat )
cout << *it;
return 0;
+ case 9: // uncheck
+ for (auto it = begin(listTodo); it != end(listTodo); ++it) {
+ bool active = true;
+ for( int i = 2 ; i < argc && active ; i++ )
+ if( it->str.find(argv[i]) == string::npos)
+ active = false;
+ if( active )
+ it->etat = 0;
+ }
+ break;
default:
cout << "Erreur : Action incomprise" << endl;
}