From 18c320a5d659090604696cd9466618e82a0d2358 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 19 Nov 2025 09:16:04 -0800 Subject: Added a print function for debugging. --- c++-libbu++/src/gatsc/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/c++-libbu++/src/gatsc/main.cpp b/c++-libbu++/src/gatsc/main.cpp index c95b914..334131c 100644 --- a/c++-libbu++/src/gatsc/main.cpp +++ b/c++-libbu++/src/gatsc/main.cpp @@ -24,6 +24,7 @@ public: Options( int argc, char *argv[] ) : bCompile( true ), bCompress( false ), + bPrint( false ), bHex( false ) { addHelpBanner("Gats Compiler\nUsage: gatsc [options] [input]\n"); @@ -33,6 +34,8 @@ public: addOption( bCompile, 'd', "decompile", "Convert binary gats to text gats."); + addOption( bPrint, 'p', "print", + "Print the structure of the input to stdout."); addOption( bCompress, 'z', "compress", "Compress with deflate."); addOption( bHex, 'x', "hex", "Encode output as hex."); @@ -43,6 +46,7 @@ public: setOverride("decompile", false ); setOverride("compress", true ); + setOverride("print", true ); setOverride("hex", true ); parse( argc, argv ); @@ -56,6 +60,7 @@ public: bool bCompile; bool bCompress; + bool bPrint; bool bHex; String sInput; String sOutput; @@ -71,6 +76,21 @@ int main( int argc, char *argv[] ) return 1; } + if( opt.bPrint ) + { + File fIn( opt.sInput, File::Read ); + Gats::GatsStream gs( fIn ); + Gats::Object *pObj = gs.readObject(); + if( pObj == NULL ) + { + println("Error reading input."); + return -1; + } + sio << *pObj << sio.nl << sio.nl; + delete pObj; + return -1; + } + if( opt.sOutput.isEmpty() ) { opt.sOutput.set( opt.sInput.begin(), opt.sInput.find('.') ); -- cgit v1.2.3