@@ -181,11 +181,11 @@ int main(int argc, char *argv[]) {
181
181
action = 4 ;
182
182
else
183
183
cout << " Erreur : Priorité non interprétable" << endl;
184
- }else if ( !strcmp ( argv[1 ], " get" ) ) {
185
- if ( argc > 2 && argv[ 2 ][ 0 ] >= ' 0 ' && argv[ 2 ][ 0 ] <= ' 9 ' )
186
- action = 5 ,color = false ;
184
+ }else if ( !strcmp ( argv[1 ], " get" ) || ! strcmp (argv[ 1 ], " g " ) ) {
185
+ if ( argc > 2 )
186
+ action = 5 ;
187
187
else
188
- cout << " Erreur : Priorité non interprétable " << endl;
188
+ cout << " Erreur : Besoin d'un sélecteur " << endl;
189
189
}else if ( !strcmp ( argv[1 ], " checked" ) ) {
190
190
action = 6 ;
191
191
}else if ( !strcmp ( argv[1 ], " clean" ) || !strcmp ( argv[1 ], " clear" )
@@ -262,11 +262,26 @@ int main(int argc, char *argv[]) {
262
262
modifyTODO ( listTodo, argc-3 , argv+3 , [priority](todo& it) { it.priorite = priority; });
263
263
}
264
264
break ;
265
- case 5 : // s
266
- for (auto it = begin (listTodo); it != end (listTodo); ++it)
267
- if ( it->priorite == atoi (argv[2 ]) )
268
- cout << *it;
265
+ case 5 : // get
266
+ {
267
+ char * res = NULL ;
268
+ int priorite = strtol (argv[2 ], &res, 0 );
269
+ if ( res != argv[2 ] && *res == ' \0 ' ) {
270
+ for (auto it = begin (listTodo); it != end (listTodo); ++it)
271
+ if ( it->priorite == priorite )
272
+ cout << *it;
273
+ } else {
274
+ for (auto it = begin (listTodo); it != end (listTodo); ++it) {
275
+ for ( int j = 2 ; j < argc ; j++ )
276
+ if ( it->str .find (argv[j]) != string::npos) {
277
+ cout << *it;
278
+ break ;
279
+ }
280
+ }
281
+ }
282
+
269
283
return 0 ;
284
+ }
270
285
case 6 : // Checked
271
286
for (auto it = begin (listTodo); it != end (listTodo); ++it)
272
287
if ( it->etat )
0 commit comments