diff --git a/docs/source/user-docs/command-line.rst b/docs/source/user-docs/command-line.rst index eac7a757..ceea4d11 100644 --- a/docs/source/user-docs/command-line.rst +++ b/docs/source/user-docs/command-line.rst @@ -4,7 +4,7 @@ Command-line Options Synopsis -------- -**Cutter** [*options*] [<*filename*>] +**Cutter** [*options*] [<*filename*> | --project <*project*>] Options @@ -52,6 +52,10 @@ Options Run script file +.. option:: -p, --project + + Load project file + .. option:: -w, --writemode Open a file in write mode, instead of the default read-only mode. diff --git a/src/CutterApplication.cpp b/src/CutterApplication.cpp index a63a5565..a1f4cf68 100644 --- a/src/CutterApplication.cpp +++ b/src/CutterApplication.cpp @@ -133,7 +133,7 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc setStyle(new CutterProxyStyle()); #endif // QT_VERSION_CHECK(5, 10, 0) < QT_VERSION - if (clOptions.args.empty()) { + if (clOptions.args.empty() && clOptions.fileOpenOptions.projectFile.isEmpty()) { // check if this is the first execution of Cutter in this computer // Note: the execution after the preferences been reset, will be considered as // first-execution @@ -142,7 +142,8 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc } mainWindow->displayNewFileDialog(); } else { // filename specified as positional argument - bool askOptions = clOptions.analLevel != AutomaticAnalysisLevel::Ask; + bool askOptions = (clOptions.analLevel != AutomaticAnalysisLevel::Ask) + || !clOptions.fileOpenOptions.projectFile.isEmpty(); mainWindow->openNewFile(clOptions.fileOpenOptions, askOptions); } @@ -332,6 +333,10 @@ bool CutterApplication::parseCommandLineOptions() QCommandLineOption scriptOption("i", QObject::tr("Run script file"), QObject::tr("file")); cmd_parser.addOption(scriptOption); + QCommandLineOption projectOption({ "p", "project" }, QObject::tr("Load project file"), + QObject::tr("project file")); + cmd_parser.addOption(projectOption); + QCommandLineOption writeModeOption({ "w", "writemode" }, QObject::tr("Open file in write mode")); cmd_parser.addOption(writeModeOption); @@ -426,6 +431,8 @@ bool CutterApplication::parseCommandLineOptions() opts.fileOpenOptions.writeEnabled = cmd_parser.isSet(writeModeOption); } + opts.fileOpenOptions.projectFile = cmd_parser.value(projectOption); + if (cmd_parser.isSet(pythonHomeOption)) { opts.pythonHome = cmd_parser.value(pythonHomeOption); } diff --git a/src/common/InitialOptions.h b/src/common/InitialOptions.h index 503ffdee..9e6413b0 100644 --- a/src/common/InitialOptions.h +++ b/src/common/InitialOptions.h @@ -18,6 +18,7 @@ struct InitialOptions enum class Endianness { Auto, Little, Big }; QString filename; + QString projectFile; bool useVA = true; RVA binLoadAddr = RVA_INVALID; diff --git a/src/core/MainWindow.cpp b/src/core/MainWindow.cpp index 0b422623..f405a2e1 100644 --- a/src/core/MainWindow.cpp +++ b/src/core/MainWindow.cpp @@ -591,7 +591,13 @@ void MainWindow::displayInitialOptionsDialog(const InitialOptions &options, bool o->loadOptions(options); if (skipOptionsDialog) { - o->setupAndStartAnalysis(); + if (!options.projectFile.isEmpty()) { + if (!openProject(options.projectFile)) { + displayNewFileDialog(); + }; + } else { + o->setupAndStartAnalysis(); + } } else { o->show(); }