aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp')
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp
new file mode 100644
index 0000000..0ca6cb6
--- /dev/null
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp
@@ -0,0 +1,34 @@
+#include "clicommandcd.h"
+#include <QCoreApplication>
+#include <QDir>
+
+void CliCommandCd::execute()
+{
+ QDir dir;
+ dir.cd(syntax.getArgument(DIR_PATH));
+ if (QDir::setCurrent(dir.absolutePath()))
+ println(tr("Changed directory to: %1").arg(QDir::currentPath()));
+ else
+ println(tr("Could not change directory to: %1").arg(QDir::currentPath()));
+}
+
+QString CliCommandCd::shortHelp() const
+{
+ return tr("changes current workind directory");
+}
+
+QString CliCommandCd::fullHelp() const
+{
+ return tr(
+ "Very similar command to 'cd' known from Unix systems and Windows. "
+ "It requires a <path> argument to be passed, therefore calling %1 will always cause a change of the directory. "
+ "To learn what's the current working directory use %2 command and to list contents of the current working directory "
+ "use %3 command."
+ );
+}
+
+void CliCommandCd::defineSyntax()
+{
+ syntax.setName("cd");
+ syntax.addArgument(DIR_PATH, tr("path", "CLI command syntax"));
+}