src/args.cpp
///////////////////////
// rename a to-do list
rename a to-do list
rename a to - do list
void renameList()
{
    TodoList *list = Core::list(name());
    if (!list->exists()){
        cout << ANSI_RED << "Todo List '" << list->name;
        cout << "' does not exist!\n" << ANSI_RESET;
        return;
    }
    string newName;
    cout << "Enter new list name, or an empty line to cancel > ";
    getline(cin, newName);
    if (newName.empty()){
        cout << "Canceling rename.\n";
        return;
    }
    if (remove(list->getPath().c_str()) != 0){
        cout << ANSI_RED << "Failed to remove list!\n" << ANSI_RESET;
        return;
    }
    string oldName = list->name;
    list->name = newName;
    if (list->exists()){
        cout << ANSI_RED << "List already exists!\n" << ANSI_RESET;
        list->name = oldName;
    } else{
       cout << "List renamed.\n"; 
    }
    list->save();    
}
void renameList ( ) { TodoList * list = Core :: list ( name ( ) ) ; if ( ! list -> exists ( ) ) { cout << ANSI_RED << " " << list -> name ; cout << " \n " << ANSI_RESET ; return ; } string newName ; cout << " " ; getline ( cin , newName ) ; if ( newName . empty ( ) ) { cout << " \n " ; return ; } if ( remove ( list -> getPath ( ) . c_str ( ) ) != 0 ) { cout << ANSI_RED << " \n " << ANSI_RESET ; return ; } string oldName = list -> name ; list -> name = newName ; if ( list -> exists ( ) ) { cout << ANSI_RED << " \n " << ANSI_RESET ; list -> name = oldName ; } else { cout << " \n " ; } list -> save ( ) ; }
rename a to-do list
rename a to - do list