1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#include "options.h"
#include "version.h"
#include "game.h"
#include <stdlib.h>
#include <bu/optparser.h>
#include <bu/sio.h>
using namespace Bu;
Options::Options()
{
}
Options::~Options()
{
}
void Options::parse( int argc, char *argv[] )
{
Bu::OptParser opt;
opt.addHelpBanner("STAGE v" VERSION
" - Simple, Textual, Adventure Game Environment");
opt.addHelpBanner("usage: " + Bu::String(argv[0]) +
" [options] <filename>\n");
opt.addOption( Bu::slot( this, &Options::version ), "version",
"Show full version info." );
opt.addOption( Bu::slot( this, &Options::builtins ), "builtins",
"List available builtins." );
opt.addHelpOption('h', "help");
opt.setNonOption( Bu::slot( this, &Options::nonOption ) );
opt.parse( argc, argv );
}
int Options::version( Bu::StrArray aArgs )
{
sio << "STAGE v" VERSION " - Simple, Textual, Adventure Game Environment."
<< sio.nl << sio.nl;
sio << "Full version: " FULLVER << sio.nl;
sio << "Build date: " TIMEVER << sio.nl;
sio << "Build id: " SHAVER << sio.nl;
sio << sio.nl;
exit( 0 );
return 0;
}
int Options::builtins( Bu::StrArray aArgs )
{
sio << "Current builtin functions:" << sio.nl;
Game g;
const Game::FunctionHash &hFnc = g.getFunctionHash();
for( Game::FunctionHash::const_iterator i = hFnc.begin(); i; i++ )
{
sio << " - " << i.getKey() << sio.nl;
}
sio << sio.nl;
exit( 0 );
return 0;
}
int Options::nonOption( Bu::Array<Bu::String> aArgs )
{
sFile = aArgs[0];
return 0;
}
|