From ccc0661a64b6acc0dd9708b1ab32a72e0a016e9c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 4 Jan 2012 22:52:48 -0700 Subject: Added --builtins command line option. --- src/game.h | 7 +++++-- src/options.cpp | 22 ++++++++++++++++++++-- src/options.h | 1 + 3 files changed, 26 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/game.h b/src/game.h index 8e2ec1b..7dc445f 100644 --- a/src/game.h +++ b/src/game.h @@ -16,18 +16,21 @@ public: Game(); virtual ~Game(); + typedef Bu::Hash FunctionHash; + typedef Bu::Hash SituationHash; + Function *getFunction( const Bu::String &sName ); Variable getParam( const Bu::String &sName ) const; Situation *getSituation( const Bu::String &sName ); + const FunctionHash &getFunctionHash() const { return hFunction; } + bool execCommand( class GameState &gState, const Bu::StringList &lCmd ); private: void addFunction( Function *pFunc ); private: - typedef Bu::Hash FunctionHash; - typedef Bu::Hash SituationHash; VariableHash hGlobalParam; FunctionHash hFunction; SituationHash hSituation; diff --git a/src/options.cpp b/src/options.cpp index 42f58a2..23a98a8 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -1,5 +1,6 @@ #include "options.h" #include "version.h" +#include "game.h" #include @@ -24,7 +25,10 @@ void Options::parse( int argc, char *argv[] ) " - Simple, Textual, Adventure Game Environment"); opt.addHelpBanner("usage: " + Bu::String(argv[0]) + " [options] \n"); - opt.addOption( Bu::slot( this, &Options::version ), Bu::String("version"), Bu::String("Show the version info.") ); + 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 ); @@ -36,7 +40,21 @@ int Options::version( Bu::StrArray aArgs ) << sio.nl << sio.nl; sio << "Full version: " FULLVER << sio.nl; sio << "Build date: " TIMEVER << sio.nl; -// sio << "Commit id: " SHAVER << 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; diff --git a/src/options.h b/src/options.h index 09ad19a..5b3f413 100644 --- a/src/options.h +++ b/src/options.h @@ -19,6 +19,7 @@ public: protected: int version( Bu::Array aArgs ); + int builtins( Bu::Array aArgs ); int nonOption( Bu::Array aArgs ); }; -- cgit v1.2.3