src/args.cpp
//////////////////////////////////////////////
// parse and act on program arguments
// returns true if the program should exit, 
// false if it should continue
parse and act on program arguments
returns true if the program should exit,
false if it should continue
parse and act on program arguments returns true if the program should exit false if it should continue
bool parseArgs(int argv, char **argc)
{
    if (argv <= 1){
        return false;
    }
    for (int i = 1; i < argv; i++){
        if (string(argc[i]) == "-h" || 
            string(argc[i]) == "-help" || 
            string(argc[i]) == "--help"){           
            printUsage();
            return true;
        } 
        else if (string(argc[i]) == "-version" ||
                 string(argc[i]) == "--version"){
            printVersion();
            return true;
        }
        else if (string(argc[i]) == "-r" ||
                 string(argc[i]) == "--rename"){
            renameList();
            return true;
        }
        else if (string(argc[i]) == "-d" ||
                 string(argc[i]) == "--delete"){
            removeList();
            return true;
        }
        else if (string(argc[i]) == "-l" ||
                 string(argc[i]) == "--list"){
            printLists();
            return true;
        }
        else if (string(argc[i]) == "-p" ||
                 string(argc[i]) == "--print"){
            printTodo();
            return true;
        }
        else if(string(argc[i]) == "-nc" ||
                string(argc[i]) == "--no-color"){
            ANSI_WHITE = ANSI_BLUE = ANSI_GREEN 
            = ANSI_RED = ANSI_RESET = "";
            colors_ = false;
        }
        else if (i != 1){
            cout << ANSI_RED;
            cout << "unknown argument \"" << argc[i] << "\"\n";
            cout << ANSI_RESET;
            cout << "run ";
            cout << ANSI_BLUE;
            cout << "todo --help "; 
            cout << ANSI_RESET; 
            cout << "for more information\n";
            return true;
        } else {        
            todoName = string(argc[1]);
        }
    }
    return false; 
}
bool parseArgs ( int argv , char * * argc ) { if ( argv <= 1 ) { return false ; } for ( int i = 1 ; i < argv ; i ++ ) { if ( string ( argc [ i ] ) == " " || string ( argc [ i ] ) == " " || string ( argc [ i ] ) == " " ) { printUsage ( ) ; return true ; } else if ( string ( argc [ i ] ) == " " || string ( argc [ i ] ) == " " ) { printVersion ( ) ; return true ; } else if ( string ( argc [ i ] ) == " " || string ( argc [ i ] ) == " " ) { renameList ( ) ; return true ; } else if ( string ( argc [ i ] ) == " " || string ( argc [ i ] ) == " " ) { removeList ( ) ; return true ; } else if ( string ( argc [ i ] ) == " " || string ( argc [ i ] ) == " " ) { printLists ( ) ; return true ; } else if ( string ( argc [ i ] ) == " " || string ( argc [ i ] ) == " " ) { printTodo ( ) ; return true ; } else if ( string ( argc [ i ] ) == " " || string ( argc [ i ] ) == " " ) { ANSI_WHITE = ANSI_BLUE = ANSI_GREEN = ANSI_RED = ANSI_RESET = " " ; colors_ = false ; } else if ( i != 1 ) { cout << ANSI_RED ; cout << " \" " << argc [ i ] << " \" \n " ; cout << ANSI_RESET ; cout << " " ; cout << ANSI_BLUE ; cout << " " ; cout << ANSI_RESET ; cout << " \n " ; return true ; } else { todoName = string ( argc [ 1 ] ) ; } } return false ; }
parse and act on program arguments
returns true if the program should exit,
false if it should continue
parse and act on program arguments returns true if the program should exit false if it should continue