diff --git a/README.md b/README.md index c5351aa2..56ce8714 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ To build the project yourself you have to build wxWidgets for your appropriate t 3) Build your target configuration DLL Debug/DLL Release. 4) Generate mdb2sqlite project using CMake selecting the required toolset. +## Command line +> mdb2sqlite.exe + ## Additional notes Does not work if database is password protected diff --git a/src/FieldStatements.h b/src/FieldStatements.h index 3ec39f8d..da060933 100644 --- a/src/FieldStatements.h +++ b/src/FieldStatements.h @@ -10,6 +10,7 @@ struct CDaoTableDefInfo; struct CDaoFieldInfo; #include "OnAction.h" +#include #ifndef __DB_FIELD_H__ #include "DBField.h" diff --git a/src/FileUtils.h b/src/FileUtils.h index 068ad7c3..54d61e9f 100644 --- a/src/FileUtils.h +++ b/src/FileUtils.h @@ -3,6 +3,7 @@ #pragma once #include +#include namespace file_utils { diff --git a/src/OnAction.cpp b/src/OnAction.cpp index 986dbddd..44e0f485 100644 --- a/src/OnAction.cpp +++ b/src/OnAction.cpp @@ -63,7 +63,7 @@ void CSettingsReader::Dumping(std::vector &statements, std::vector statements, InsertStatements, RelationFields, IndexStatements, UniqueFields, CollateIndexFields, @@ -156,7 +156,7 @@ bool CSettingsReader::Control(const char *Path, const char *dPath, CUIObs *pObs, } } - if( bConvert ) + if( bConvert && !bCmd) { CStructPreviewDlg dlg(nullptr, structure); bool bOK = dlg.ShowModal() == wxID_OK; diff --git a/src/OnAction.h b/src/OnAction.h index 65c3cb8b..6e2924ca 100644 --- a/src/OnAction.h +++ b/src/OnAction.h @@ -32,7 +32,7 @@ class CSettingsReader { public: static void ReadFromCSimpleIni(CSettings &settings); - static bool Control(const char *Path, const char *dPath, CUIObs *pObs, bool bConvert); + static bool Control(const char *Path, const char *dPath, CUIObs *pObs, bool bConvert, bool bCmd); private: static void Dumping(std::vector &statements, std::vector &InsertStatements, std::vector &RelationFields, std::vector &IndexStatements, const char *&dPath); diff --git a/src/mdb2sqlite.cpp b/src/mdb2sqlite.cpp index 6c159ccc..c20f5432 100644 --- a/src/mdb2sqlite.cpp +++ b/src/mdb2sqlite.cpp @@ -30,10 +30,45 @@ namespace internal wxMessageDialog dlg(pParent, sMsg, sTitle); dlg.ShowModal(); } + + class CUIObsCmdImpl : public CUIObs + { + public: + virtual void CreateAdditionalItems() override { }; + virtual void SetDefaultStyle(const wxTextAttr &atr) override { }; + virtual void WriteText(std::wstring sMsg) override { }; + virtual void SetRange(int nRange) override { }; + virtual void SetValue(int nValue) override { }; + }; + + static bool UseCommandLine(int argc, const wxCmdLineArgsArray &argv) + { + if (3 == argc) { + const wxString sSource = argv[1]; + const wxString sTarget = argv[2]; + + if (sSource.empty() || sTarget.empty()) { + return false; + } + + CUIObsCmdImpl obsImpl; + + const bool bRet = CSettingsReader::Control(sSource.mb_str(), sTarget.mb_str(), &obsImpl, true, true); + if (bRet) { + return true; + } + } + + return false; + } }; bool MyApp::OnInit() { + if (internal::UseCommandLine(argc, argv)) { + return false; + } + int nPosX, nPosY, nSizeX; file_utils::GetWindowInformation(nPosX, nPosY, nSizeX); @@ -151,7 +186,7 @@ void CMainDlg::OnDump( wxCommandEvent &WXUNUSED(event) ) const char *pSrcPath = sSrcPath.mb_str(); const char *pDstPath = sDstPath.mb_str(); - CSettingsReader::Control(pSrcPath, pDstPath, this, false); + CSettingsReader::Control(pSrcPath, pDstPath, this, false, false); internal::ShowMessageDlg(this, wxT("Succesfully dumped."), wxT("Dump information")); } @@ -174,7 +209,7 @@ void CMainDlg::OnConvert(wxCommandEvent &WXUNUSED(event) ) const char *pSrcPath = sPathMDB.mb_str(); const char *pDPath = sPathSQLite.mb_str(); - bool bRet = CSettingsReader::Control(pSrcPath, pDPath, this, true); + bool bRet = CSettingsReader::Control(pSrcPath, pDPath, this, true, false); if( bRet ) internal::ShowMessageDlg(this, wxString::Format(wxT("Succesfully exported %s to SQLite"), sFilename), wxT("Succesfully exported to SQLite")); } diff --git a/src/sqlitestatementexecution.h b/src/sqlitestatementexecution.h index d17b210c..f60dde70 100644 --- a/src/sqlitestatementexecution.h +++ b/src/sqlitestatementexecution.h @@ -4,6 +4,7 @@ #pragma once #include +#include class CUIObs; struct sqlite3;