Changeset 612

Show
Ignore:
Timestamp:
07/24/08 11:52:14 (4 months ago)
Author:
weyrick
Message:

parse commandline options

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/rphp/frontend/cli/CMakeLists.txt

    r611 r612  
    99 
    1010add_executable( rphp ${CLI_SRC_FILES} ) 
    11 target_link_libraries( rphp rphp-eval rphp-runtime
     11target_link_libraries( rphp rphp-eval rphp-runtime boost_program_options
    1212 
  • trunk/rphp/frontend/cli/main.cpp

    r611 r612  
    11 
    22#include <iostream> 
     3#include <vector> 
     4#include <string> 
     5#include <boost/program_options.hpp> 
    36#include "pDriver.h" 
     7 
     8namespace po = boost::program_options; 
    49 
    510int main( int argc, char* argv[] ) 
     
    712 
    813    rphp::pDriver driver; 
     14 
     15    //int opt; 
     16    po::options_description desc("Allowed options"); 
     17    desc.add_options() 
     18        ("help", "produce help message") 
     19//        ("optimization", po::value<int>(&opt)->default_value(10), "optimization level") 
     20        ("input-file", po::value< std::vector<std::string> >(), "input file") 
     21        ; 
     22 
     23    po::positional_options_description p; 
     24    p.add("input-file", -1); 
     25 
     26    po::variables_map vm; 
     27    po::store(po::command_line_parser(argc, argv). 
     28            options(desc).positional(p).run(), vm); 
     29    po::notify(vm); 
     30 
     31    if (vm.count("help") || !vm.count("input-file")) { 
     32        std::cout << desc << "\n"; 
     33        return 1; 
     34    } 
    935     
    1036    std::cout << "Roadsend PHP" << std::endl; 
    11     driver.compile("fiddle.php"); 
    1237 
     38    std::vector<std::string> infiles = vm["input-file"].as< std::vector<std::string> >(); 
     39    for (std::vector<std::string>::iterator it = infiles.begin(); it!=infiles.end(); ++it) { 
     40        driver.compile(*it); 
     41    } 
     42 
     43    //std::cout << "Optimization level is " << opt << "\n"; 
     44  
    1345}