diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/options.cpp | 19 | ||||
-rw-r--r-- | src/options.h | 3 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/options.cpp b/src/options.cpp index 7953add..aa964d2 100644 --- a/src/options.cpp +++ b/src/options.cpp | |||
@@ -1,7 +1,12 @@ | |||
1 | #include "options.h" | 1 | #include "options.h" |
2 | #include "version.h" | 2 | #include "version.h" |
3 | 3 | ||
4 | #include <stdlib.h> | ||
5 | |||
4 | #include <bu/optparser.h> | 6 | #include <bu/optparser.h> |
7 | #include <bu/sio.h> | ||
8 | |||
9 | using namespace Bu; | ||
5 | 10 | ||
6 | Options::Options() | 11 | Options::Options() |
7 | { | 12 | { |
@@ -15,11 +20,23 @@ void Options::parse( int argc, char *argv[] ) | |||
15 | { | 20 | { |
16 | Bu::OptParser opt; | 21 | Bu::OptParser opt; |
17 | 22 | ||
18 | opt.addHelpBanner("STAGE v" FULLVER | 23 | opt.addHelpBanner("STAGE v" VERSION |
19 | " - Simple, Textual, Adventure Game Environment"); | 24 | " - Simple, Textual, Adventure Game Environment"); |
20 | opt.addHelpBanner("usage: " + Bu::String(argv[0]) + | 25 | opt.addHelpBanner("usage: " + Bu::String(argv[0]) + |
21 | " [options] <filename>\n"); | 26 | " [options] <filename>\n"); |
27 | opt.addOption( Bu::slot( this, &Options::version ), Bu::String("version"), Bu::String("Show the version info.") ); | ||
22 | opt.addHelpOption('h', "help"); | 28 | opt.addHelpOption('h', "help"); |
23 | opt.parse( argc, argv ); | 29 | opt.parse( argc, argv ); |
24 | } | 30 | } |
25 | 31 | ||
32 | int Options::version( Bu::StrArray aArgs ) | ||
33 | { | ||
34 | sio << "STAGE v" VERSION " - Simple, Textual, Adventure Game Environment." | ||
35 | << sio.nl; | ||
36 | sio << "Full version: " FULLVER << sio.nl; | ||
37 | sio << "Commit id: " SHAVER << sio.nl; | ||
38 | sio << sio.nl; | ||
39 | exit( 0 ); | ||
40 | return 0; | ||
41 | } | ||
42 | |||
diff --git a/src/options.h b/src/options.h index 42caa53..7fe2633 100644 --- a/src/options.h +++ b/src/options.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <bu/singleton.h> | 4 | #include <bu/singleton.h> |
5 | #include <bu/string.h> | 5 | #include <bu/string.h> |
6 | #include <bu/array.h> | ||
6 | 7 | ||
7 | class Options : public Bu::Singleton<Options> | 8 | class Options : public Bu::Singleton<Options> |
8 | { | 9 | { |
@@ -15,6 +16,8 @@ public: | |||
15 | void parse( int argc, char *argv[] ); | 16 | void parse( int argc, char *argv[] ); |
16 | 17 | ||
17 | Bu::String sFile; | 18 | Bu::String sFile; |
19 | |||
20 | int version( Bu::Array<Bu::String> aArgs ); | ||
18 | }; | 21 | }; |
19 | 22 | ||
20 | #endif | 23 | #endif |