Subversion Repositories gelsvn

Rev

Rev 561 | Rev 601 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 561 Rev 563
Line 31... Line 31...
31
{
31
{
32
    load_history();
32
    load_history();
33
 
33
 
34
    //register builtin commands
34
    //register builtin commands
35
    void (Console::*help0)() = &Console::help;
35
    void (Console::*help0)() = &Console::help;
36
    reg_cmd("help",
36
    reg_cmd0("help",
37
            std::bind(help0, this), "Print list of commands.");
37
             std::bind(help0, this), "Print list of commands.");
38
 
38
 
39
    void (Console::*help1)(const std::string&) = &Console::help;
39
    void (Console::*help1)(const std::string&) = &Console::help;
40
    reg_cmd<std::string>("help", std::bind(help1, this, std::placeholders::_1),
40
    reg_cmd1<std::string>("help", std::bind(help1, this, std::placeholders::_1),
41
                         "Show help for specified command.");
41
                          "Show help for specified command.");
42
 
42
 
43
    reg_cmd("clear", std::bind(&Console::clear, this), "Clear console.");
43
    reg_cmd0("clear", std::bind(&Console::clear, this), "Clear console.");
44
 
44
 
45
    reg_cmd("history", std::bind(&Console::history, this),
45
    reg_cmd0("history", std::bind(&Console::history, this),
46
            "Show history of commands.");
46
             "Show history of commands.");
47
    reg_cmd("clear_history", std::bind(&Console::history, this),
47
    reg_cmd0("clear_history", std::bind(&Console::history, this),
48
            "Clear history of commands.");
48
             "Clear history of commands.");
49
    reg_cmd("load_history", std::bind(&Console::load_history, this),
49
    reg_cmd0("load_history", std::bind(&Console::load_history, this),
50
            "Load history of commands from file.");
50
             "Load history of commands from file.");
51
    reg_cmd("save_history", std::bind(&Console::save_history, this),
51
    reg_cmd0("save_history", std::bind(&Console::save_history, this),
52
            "Save history of commands to file.");
52
             "Save history of commands to file.");
53
}
53
}
54
 
54
 
55
Console::~Console() throw()
55
Console::~Console() throw()
56
{
56
{
57
    save_history();
57
    save_history();
Line 451... Line 451...
451
 
451
 
452
     //find command with right number of arguments and execute
452
     //find command with right number of arguments and execute
453
    command_map_t::const_iterator it;
453
    command_map_t::const_iterator it;
454
     for (it=rng.first; it!=rng.second; ++it)
454
     for (it=rng.first; it!=rng.second; ++it)
455
     {
455
     {
-
 
456
         size_t arity = it->second->arity();
456
         if (it->second->arity() != args.size())
457
         if (arity!=any_arity && arity!=args.size())
457
             continue;
458
             continue;
458
 
459
 
459
         m_is_executing = true;
460
         m_is_executing = true;
460
 
461
 
461
         try {
462
         try {
Line 703... Line 704...
703
    printf("Printing help for command(s) '%s':", cmd.c_str());
704
    printf("Printing help for command(s) '%s':", cmd.c_str());
704
 
705
 
705
    for (command_map_t::const_iterator it=rng.first; it!=rng.second; ++it)
706
    for (command_map_t::const_iterator it=rng.first; it!=rng.second; ++it)
706
    {
707
    {
707
        std::stringstream ss;
708
        std::stringstream ss;
-
 
709
        if (it->second->arity() != any_arity)
708
        for (size_t i=0; i<it->second->arity(); ++i)
710
            for (size_t i=0; i<it->second->arity(); ++i)
709
            ss << "arg" << i << " ";
711
                ss << "arg" << i << " ";
-
 
712
        else
-
 
713
            ss << "arg0, arg1, .., argN";
710
 
714
 
711
        printf("  %s %s: %s",
715
        printf("  %s %s: %s",
712
            it->first.c_str(), ss.str().c_str(),
716
            it->first.c_str(), ss.str().c_str(),
713
            it->second->get_help());
717
            it->second->get_help());
714
    }
718
    }