mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-23 21:35:28 +00:00
Support loading projects from the command line (#2606)
This commit is contained in:
parent
7491434dc4
commit
42f01fcf5d
@ -4,7 +4,7 @@ Command-line Options
|
|||||||
Synopsis
|
Synopsis
|
||||||
--------
|
--------
|
||||||
|
|
||||||
**Cutter** [*options*] [<*filename*>]
|
**Cutter** [*options*] [<*filename*> | --project <*project*>]
|
||||||
|
|
||||||
|
|
||||||
Options
|
Options
|
||||||
@ -52,6 +52,10 @@ Options
|
|||||||
|
|
||||||
Run script file
|
Run script file
|
||||||
|
|
||||||
|
.. option:: -p, --project <file>
|
||||||
|
|
||||||
|
Load project file
|
||||||
|
|
||||||
.. option:: -w, --writemode
|
.. option:: -w, --writemode
|
||||||
|
|
||||||
Open a file in write mode, instead of the default read-only mode.
|
Open a file in write mode, instead of the default read-only mode.
|
||||||
|
@ -133,7 +133,7 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
|
|||||||
setStyle(new CutterProxyStyle());
|
setStyle(new CutterProxyStyle());
|
||||||
#endif // QT_VERSION_CHECK(5, 10, 0) < QT_VERSION
|
#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
|
// check if this is the first execution of Cutter in this computer
|
||||||
// Note: the execution after the preferences been reset, will be considered as
|
// Note: the execution after the preferences been reset, will be considered as
|
||||||
// first-execution
|
// first-execution
|
||||||
@ -142,7 +142,8 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
|
|||||||
}
|
}
|
||||||
mainWindow->displayNewFileDialog();
|
mainWindow->displayNewFileDialog();
|
||||||
} else { // filename specified as positional argument
|
} 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);
|
mainWindow->openNewFile(clOptions.fileOpenOptions, askOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,6 +333,10 @@ bool CutterApplication::parseCommandLineOptions()
|
|||||||
QCommandLineOption scriptOption("i", QObject::tr("Run script file"), QObject::tr("file"));
|
QCommandLineOption scriptOption("i", QObject::tr("Run script file"), QObject::tr("file"));
|
||||||
cmd_parser.addOption(scriptOption);
|
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" },
|
QCommandLineOption writeModeOption({ "w", "writemode" },
|
||||||
QObject::tr("Open file in write mode"));
|
QObject::tr("Open file in write mode"));
|
||||||
cmd_parser.addOption(writeModeOption);
|
cmd_parser.addOption(writeModeOption);
|
||||||
@ -426,6 +431,8 @@ bool CutterApplication::parseCommandLineOptions()
|
|||||||
opts.fileOpenOptions.writeEnabled = cmd_parser.isSet(writeModeOption);
|
opts.fileOpenOptions.writeEnabled = cmd_parser.isSet(writeModeOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
opts.fileOpenOptions.projectFile = cmd_parser.value(projectOption);
|
||||||
|
|
||||||
if (cmd_parser.isSet(pythonHomeOption)) {
|
if (cmd_parser.isSet(pythonHomeOption)) {
|
||||||
opts.pythonHome = cmd_parser.value(pythonHomeOption);
|
opts.pythonHome = cmd_parser.value(pythonHomeOption);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ struct InitialOptions
|
|||||||
enum class Endianness { Auto, Little, Big };
|
enum class Endianness { Auto, Little, Big };
|
||||||
|
|
||||||
QString filename;
|
QString filename;
|
||||||
|
QString projectFile;
|
||||||
|
|
||||||
bool useVA = true;
|
bool useVA = true;
|
||||||
RVA binLoadAddr = RVA_INVALID;
|
RVA binLoadAddr = RVA_INVALID;
|
||||||
|
@ -591,7 +591,13 @@ void MainWindow::displayInitialOptionsDialog(const InitialOptions &options, bool
|
|||||||
o->loadOptions(options);
|
o->loadOptions(options);
|
||||||
|
|
||||||
if (skipOptionsDialog) {
|
if (skipOptionsDialog) {
|
||||||
|
if (!options.projectFile.isEmpty()) {
|
||||||
|
if (!openProject(options.projectFile)) {
|
||||||
|
displayNewFileDialog();
|
||||||
|
};
|
||||||
|
} else {
|
||||||
o->setupAndStartAnalysis();
|
o->setupAndStartAnalysis();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
o->show();
|
o->show();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user