Rename "sh"/"cmd" => "cli"
MODIFY
main.cpp
main.cpp
#include <QTimer>
#include <iostream>
-#include "src/cmd/cmdoptions.h"
-#include "src/cmd/cmdrunner.h"
+#include "src/cli/clioptions.h"
+#include "src/cli/clirunner.h"
#include "src/mainwindow.h"
using namespace std;
-void initParser(QCommandLineParser &parser, Ripes::CmdModeOptions &options) {
+void initParser(QCommandLineParser &parser, Ripes::CLIModeOptions &options) {
QString helpText =
"The command line interface allows for assembling/compiling/executing a "
"\n"
@@ -22,16 +22,16 @@ void initParser(QCommandLineParser &parser, Ripes::CmdModeOptions &options) {
helpText.prepend("Ripes command line interface.\n");
parser.setApplicationDescription(helpText);
- QCommandLineOption modeOption("mode", "Ripes mode [gui, sh]", "mode", "gui");
+ QCommandLineOption modeOption("mode", "Ripes mode [gui, cli]", "mode", "gui");
parser.addOption(modeOption);
- Ripes::addCmdOptions(parser, options);
+ Ripes::addCLIOptions(parser, options);
}
enum CommandLineParseResult {
CommandLineError,
CommandLineHelpRequested,
CommandLineGUI,
- CommandLineCMD
+ CommandLineCLI
};
CommandLineParseResult parseCommandLine(QCommandLineParser &parser,
@@ -47,8 +47,8 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser,
if (parser.value("mode") == "gui")
return CommandLineGUI;
- else if (parser.value("mode") == "sh")
- return CommandLineCMD;
+ else if (parser.value("mode") == "cli")
+ return CommandLineCLI;
else {
errorMessage = "Invalid mode: " + parser.value("mode");
return CommandLineError;
@@ -69,14 +69,14 @@ int guiMode(QApplication &app) {
return app.exec();
}
-int cmdMode(QCommandLineParser &parser, Ripes::CmdModeOptions &options) {
+int CLIMode(QCommandLineParser &parser, Ripes::CLIModeOptions &options) {
QString err;
- if (!Ripes::parseCmdOptions(parser, err, options)) {
+ if (!Ripes::parseCLIOptions(parser, err, options)) {
std::cerr << "ERROR: " << err.toStdString() << std::endl;
parser.showHelp();
return 0;
}
- return Ripes::CmdRunner(options).run();
+ return Ripes::CLIRunner(options).run();
}
int main(int argc, char **argv) {
@@ -89,7 +89,7 @@ int main(int argc, char **argv) {
QCoreApplication::setApplicationName("Ripes");
QCommandLineParser parser;
- Ripes::CmdModeOptions options;
+ Ripes::CLIModeOptions options;
initParser(parser, options);
QString err;
switch (parseCommandLine(parser, err)) {
@@ -102,7 +102,7 @@ int main(int argc, char **argv) {
return 0;
case CommandLineGUI:
return guiMode(app);
- case CommandLineCMD:
- return cmdMode(parser, options);
+ case CommandLineCLI:
+ return CLIMode(parser, options);
}
}

MODIFY
src/CMakeLists.txt
src/CMakeLists.txt
@@ -65,7 +65,7 @@ add_subdirectory(io)
add_subdirectory(utilities)
add_subdirectory(processors)
add_subdirectory(version)
-add_subdirectory(cmd)
+add_subdirectory(cli)
# Also link Qt and VSRTL libraries.
target_link_libraries(${RIPES_LIB} PUBLIC

ADD
src/cli/CMakeLists.txt
+create_ripes_lib(CLI LINK_TO_RIPES_LIB)

RENAME
src/cmd/cmdoptions.cpp
src/cli/clioptions.cpp
-#include "cmdoptions.h"
+#include "clioptions.h"
#include "processorregistry.h"
#include "telemetry.h"
#include <QFile>
namespace Ripes {
-void addCmdOptions(QCommandLineParser &parser, Ripes::CmdModeOptions &options) {
+void addCLIOptions(QCommandLineParser &parser, Ripes::CLIModeOptions &options) {
parser.addOption(QCommandLineOption("src", "Source file", "src"));
parser.addOption(QCommandLineOption(
"t", "Source type. Options: [c, asm, bin]", "type", "asm"));
@@ -54,8 +54,8 @@ void addCmdOptions(QCommandLineParser &parser, Ripes::CmdModeOptions &options) {
}
}
-bool parseCmdOptions(QCommandLineParser &parser, QString &errorMessage,
- CmdModeOptions &options) {
+bool parseCLIOptions(QCommandLineParser &parser, QString &errorMessage,
+ CLIModeOptions &options) {
options.verbose = parser.isSet("v");
if (!parser.isSet("src")) {

RENAME
src/cmd/cmdoptions.h
src/cli/clioptions.h
namespace Ripes {
-struct CmdModeOptions {
+struct CLIModeOptions {
QString src;
SourceType srcType;
ProcessorID proc;
@@ -22,11 +22,12 @@ struct CmdModeOptions {
std::vector<std::shared_ptr<Telemetry>> telemetry;
};
-/// Adds Ripes command-line mode options to a parser.
-void addCmdOptions(QCommandLineParser &parser, Ripes::CmdModeOptions &options);
-/// Parses Ripes command-line mode options to a CmdModeOptions struct. Returns
+/// Adds Ripes CLI options to a parser.
+void addCLIOptions(QCommandLineParser &parser, Ripes::CLIModeOptions &options);
+
+/// Parses Ripes CLI mode options to a CLIModeOptions struct. Returns
/// true if options were parsed successfully.
-bool parseCmdOptions(QCommandLineParser &parser, QString &errorMessage,
- CmdModeOptions &options);
+bool parseCLIOptions(QCommandLineParser &parser, QString &errorMessage,
+ CLIModeOptions &options);
} // namespace Ripes

RENAME
src/cmd/cmdrunner.cpp
src/cli/clirunner.cpp
-#include "cmdrunner.h"
+#include "clirunner.h"
#include "io/iomanager.h"
#include "processorhandler.h"
#include "programutilities.h"
@@ -32,9 +32,9 @@ static QString qVariantToString(QVariant &v) {
return def;
}
-CmdRunner::CmdRunner(const CmdModeOptions &options)
+CLIRunner::CLIRunner(const CLIModeOptions &options)
: QObject(), m_options(options) {
- info("Ripes command-line mode", false, true);
+ info("Ripes CLI mode", false, true);
ProcessorHandler::selectProcessor(m_options.proc, m_options.isaExtensions);
// Connect systemIO output to stdout.
@@ -46,7 +46,7 @@ CmdRunner::CmdRunner(const CmdModeOptions &options)
// TODO: how to handle system input?
}
-int CmdRunner::run() {
+int CLIRunner::run() {
if (processInput())
return 1;
@@ -59,7 +59,7 @@ int CmdRunner::run() {
return 0;
}
-int CmdRunner::processInput() {
+int CLIRunner::processInput() {
info("Processing input file", false, true);
switch (m_options.srcType) {
@@ -101,7 +101,7 @@ int CmdRunner::processInput() {
return 0;
}
-int CmdRunner::runModel() {
+int CLIRunner::runModel() {
info("Running model", false, true);
// Wait until receiving ProcessorHandler::runFinished signal
@@ -131,7 +131,7 @@ int CmdRunner::runModel() {
return 0;
}
-int CmdRunner::postRun() {
+int CLIRunner::postRun() {
info("Post-run", false, true);
// Open output stream
@@ -174,7 +174,7 @@ int CmdRunner::postRun() {
return 0;
}
-void CmdRunner::info(QString msg, bool alwaysPrint, bool header,
+void CLIRunner::info(QString msg, bool alwaysPrint, bool header,
const QString &prefix) {
if (m_options.verbose || alwaysPrint) {
@@ -194,6 +194,6 @@ void CmdRunner::info(QString msg, bool alwaysPrint, bool header,
}
}
-void CmdRunner::error(const QString &msg) { info(msg, true, false, "ERROR"); }
+void CLIRunner::error(const QString &msg) { info(msg, true, false, "ERROR"); }
} // namespace Ripes

RENAME
src/cmd/cmdrunner.h
src/cli/clirunner.h
#pragma once
-#include "cmdoptions.h"
+#include "clioptions.h"
#include <QObject>
namespace Ripes {
-/// The CmdRunner class is used to run Ripes in command-line mode.
-/// Based on a CmdModeOptions struct, it will run the appropriate combination
+/// The CLIRunner class is used to run Ripes in CLI mode.
+/// Based on a CLIModeOptions struct, it will run the appropriate combination
/// of source processing (assembler/compiler/...), processor model execution
/// as well as telemetry gathering and reporting.
-class CmdRunner : public QObject {
+class CLIRunner : public QObject {
Q_OBJECT
public:
- CmdRunner(const CmdModeOptions &options);
+ CLIRunner(const CLIModeOptions &options);
- /// Runs the command-line mode.
+ /// Runs the CLI mode.
int run();
private:
@@ -30,7 +30,7 @@ private:
const QString &prefix = "INFO");
void error(const QString &msg);
- CmdModeOptions m_options;
+ CLIModeOptions m_options;
};
} // namespace Ripes

RENAME
src/cmd/programutilities.cpp
src/cli/programutilities.cpp
RENAME
src/cmd/programutilities.h
src/cli/programutilities.h
RENAME
src/cmd/telemetry.h
src/cli/telemetry.h
DELETE
src/cmd/CMakeLists.txt
-create_ripes_lib(cmd LINK_TO_RIPES_LIB)

MODIFY
src/edittab.cpp
src/edittab.cpp
#include "assembler/program.h"
#include "ccmanager.h"
-#include "cmd/programutilities.h"
+#include "cli/programutilities.h"
#include "compilererrordialog.h"
#include "editor/codeeditor.h"
#include "io/iomanager.h"

Rename "sh"/"cmd" => "cli"