/************************** * * * * * * * * * * * * *************************** Copyright (c) 1999-2005 Ryan Bobko ryan@ostrich-emulators.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ************************** * * * * * * * * * * * * ***************************/ #ifdef HAVE_CONFIG_H #include "config.h" #else #define VERSION 3.1 #endif #include "qhacccli.h" #include "qhacc.h" #include "qhaccext.h" #include "qhaccutils.h" #include "qhacctable.h" #include "guiconstants.h" #include "qhaccsegmenter.h" #include "qhaccconstants.h" #include "localfileplugin.h" #include #include #include QHaccCLI::QHaccCLI( QHacc * eng ){ engine=eng; } QHaccCLI::~QHaccCLI(){} bool QHaccCLI::save(){ QString err; std::ostream * str=0; bool good=engine->save( err ); if( !good && Utils::error( Utils::ERRFATAL, str ) ) *str<getPluginFor( QHacc::PIREPORTER, homename, tpi ); if( tpi==0 ){ if( writerrs ) *err<<"No plugin for: "<setup( engine ); QString tit, emsg; auto_ptr data=pi->generate( homer, tit, emsg, cont ); if( cont ) *str<writereport( tit, data.get() )<destroyPlugin( QHacc::PIREPORTER, tpi ); } } } void QHaccCLI::plugins(){ std::ostream * str=0; if( Utils::debug( Utils::PRINT, str ) ){ QString output( "QHacc Available Plugins" ); const char * titles[]={ "Database", "Import", "Export", "Reporting", "Graphing" }; int types[]={ QHacc::PIDATABASE, QHacc::PIIMPORTER, QHacc::PIEXPORTER, QHacc::PIREPORTER, QHacc::PIGRAPHER }; for( int p=0; p<5; p++ ){ int curr=0; vectorpis( engine->getPluginInfo( types[p], &curr ) ); output.append( "\n" ).append( titles[p] ).append( ":" ); int i=0; for ( vector::iterator it=pis.begin(); it!=pis.end(); it++ ){ output+="\n "; if( i++==curr ) output+="*"; else output+=" "; output+=QString( "%1 (%2): %3" ).arg( it->stub() ).arg( it->descr() ).arg( it->fname() ); } } *str< set QHacc's locale"<] set debugging output"<] generate report"<] import data from QHACC_HOME"<] export data to directory"< reconcile transactions from QHACC_HOME"<] make a QHACC_HOME creation script"<=argc ) helpQuit( argv[0] ); Utils::setDebug( QString( argv[i+1] ).toInt() ); } if( !qhacc.setHome( qhome ) ) return EXIT_FAILURE; } if( cmp( argv[i], "--debug" ) ){ Utils::setDebug( QString( opt( argc, argv, i ) ).toInt() ); } else if( cmp( argv[i], "-l" ) ) langdir=opt( argc, argv, i ); else if( cmp( argv[i], "--report" ) ) cli.report( opt( argc, argv, i ) ); else if( cmp( argv[i], "--reconcile" ) )cli.reco( opt( argc, argv, i ) ); else if( cmp( argv[i], "--export" ) ) cli.exp( opt( argc, argv, i ) ); else if( cmp( argv[i], "--import" ) ) cli.imp( opt( argc, argv, i ) ); else if( cmp( argv[i], "--verifydb" ) ) cli.verify( false ); else if( cmp( argv[i], "--fixdb" ) ) cli.verify( true ); else helpQuit( argv[0] ); } } // else ( if is --create loop) return EXIT_SUCCESS; }