aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/sqlitestudiocli/commands
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2023-04-30 18:30:36 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2023-04-30 18:30:36 -0400
commit3565aad630864ecdbe53fdaa501ea708555b3c7c (patch)
treec743e4ad0bad39ebdb2f514c7cc52d34a257ebbe /SQLiteStudio3/sqlitestudiocli/commands
parent1fdc150116cad39aae5c5da407c3312b47a59e3a (diff)
New upstream version 3.4.4+dfsg.upstream/3.4.4+dfsg
Diffstat (limited to 'SQLiteStudio3/sqlitestudiocli/commands')
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommand.cpp2
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp2
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommandclose.cpp6
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommanddblist.cpp2
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommanddesc.cpp6
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommandhelp.cpp5
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommandmode.cpp2
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommandopen.cpp4
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommandpwd.cpp2
-rw-r--r--SQLiteStudio3/sqlitestudiocli/commands/clicommandsql.cpp32
10 files changed, 32 insertions, 31 deletions
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommand.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommand.cpp
index e23a042..ee201e0 100644
--- a/SQLiteStudio3/sqlitestudiocli/commands/clicommand.cpp
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommand.cpp
@@ -104,7 +104,7 @@ void CliCommand::printBox(const QString& str)
void CliCommand::printUsage()
{
- println(tr("Usage: %1%2").arg(CFG_CLI.Console.CommandPrefixChar.get()).arg(usage()));
+ println(tr("Usage: %1%2").arg(CFG_CLI.Console.CommandPrefixChar.get(), usage()));
println("");
}
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp
index 14e91d5..80de0fa 100644
--- a/SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommandcd.cpp
@@ -24,7 +24,7 @@ QString CliCommandCd::fullHelp() const
"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."
- );
+ ).arg(cmdName("cd"), cmdName("pwd"), cmdName("ls"));
}
void CliCommandCd::defineSyntax()
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommandclose.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommandclose.cpp
index 44fc72c..c2bb803 100644
--- a/SQLiteStudio3/sqlitestudiocli/commands/clicommandclose.cpp
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommandclose.cpp
@@ -8,7 +8,7 @@ void CliCommandClose::execute()
if (!syntax.isArgumentSet(DB_NAME) && !cli->getCurrentDb())
{
println(tr("Cannot call %1 when no database is set to be current. Specify current database with %2 command or pass database name to %3.")
- .arg(cmdName("close")).arg(cmdName("use")).arg(cmdName("close")));
+ .arg(cmdName("close"), cmdName("use"), cmdName("close")));
return;
}
@@ -21,7 +21,7 @@ void CliCommandClose::execute()
println(tr("Connection to database %1 closed.").arg(db->getName()));
}
else
- println(tr("No such database: %1. Use %2 to see list of known databases.").arg(syntax.getArgument(DB_NAME)).arg(cmdName("dblist")));
+ println(tr("No such database: %1. Use %2 to see list of known databases.").arg(syntax.getArgument(DB_NAME), cmdName("dblist")));
}
else if (cli->getCurrentDb())
{
@@ -41,7 +41,7 @@ QString CliCommandClose::fullHelp() const
"Closes database connection. If the database was already closed, nothing happens. "
"If <name> is provided, it should be name of the database to close (as printed by %1 command). "
"The the <name> is not provided, then current working database is closed (see help for %2 for details)."
- ).arg(cmdName("dblist")).arg(cmdName("use"));
+ ).arg(cmdName("dblist"), cmdName("use"));
}
void CliCommandClose::defineSyntax()
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommanddblist.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommanddblist.cpp
index 271a44f..6e1f7d7 100644
--- a/SQLiteStudio3/sqlitestudiocli/commands/clicommanddblist.cpp
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommanddblist.cpp
@@ -49,7 +49,7 @@ void CliCommandDbList::execute()
for (Db* db : dbList)
{
bool open = db->isOpen();
- path = db->getPath();
+ path = QDir::toNativeSeparators(db->getPath());
name = db->getName();
if (name == currentName)
name.prepend("*");
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommanddesc.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommanddesc.cpp
index f32b75e..42bd5ce 100644
--- a/SQLiteStudio3/sqlitestudiocli/commands/clicommanddesc.cpp
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommanddesc.cpp
@@ -15,7 +15,7 @@ void CliCommandDesc::execute()
println(tr("No working database is set.\n"
"Call %1 command to set working database.\n"
"Call %2 to see list of all databases.")
- .arg(cmdName("use")).arg(cmdName("dblist")));
+ .arg(cmdName("use"), cmdName("dblist")));
return;
}
@@ -54,7 +54,7 @@ QString CliCommandDesc::shortHelp() const
QString CliCommandDesc::fullHelp() const
{
- return QString();
+ return shortHelp();
}
void CliCommandDesc::defineSyntax()
@@ -84,7 +84,7 @@ void CliCommandDesc::printTable(SqliteCreateTable *table)
// Rows
QString constrJoinStr = "\n" + pad("", 20, ' ') + "|" + pad("", 10, ' ') + "|";
QStringList constrList;
- for (SqliteCreateTable::Column* column : table->columns)
+ for (SqliteCreateTable::Column*& column : table->columns)
{
msg = pad(column->name.left(20), 20, ' ');
msg += "|";
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommandhelp.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommandhelp.cpp
index 5f92fd4..bb3f9a8 100644
--- a/SQLiteStudio3/sqlitestudiocli/commands/clicommandhelp.cpp
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommandhelp.cpp
@@ -24,7 +24,7 @@ QString CliCommandHelp::fullHelp() const
"When passing <command> name, you can skip special prefix character ('%3').\n\n"
"You can always execute any command with exactly single '--help' option to see help for that command. "
"It's an alternative for typing: %1 <command>."
- ).arg(cmdName("help")).arg(cmdName("help")).arg(CFG_CLI.Console.CommandPrefixChar.get()).arg(cmdName("help"));
+ ).arg(cmdName("help"), cmdName("help"), CFG_CLI.Console.CommandPrefixChar.get(), cmdName("help"));
}
void CliCommandHelp::defineSyntax()
@@ -49,7 +49,7 @@ void CliCommandHelp::printHelp(const QString& cmd)
QString prefix = CFG_CLI.Console.CommandPrefixChar.get();
QString msg;
- msg += tr("Usage: %1%2").arg(prefix).arg(command->usage(cmdStr));
+ msg += tr("Usage: %1%2").arg(prefix, command->usage(cmdStr));
msg += "\n";
if (aliases.size() > 0)
{
@@ -83,4 +83,5 @@ void CliCommandHelp::printHelp()
delete allCommands[cmd];
}
printBox(msgList.join("\n"));
+ printHelp("help");
}
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommandmode.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommandmode.cpp
index b258045..b0419d5 100644
--- a/SQLiteStudio3/sqlitestudiocli/commands/clicommandmode.cpp
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommandmode.cpp
@@ -49,7 +49,7 @@ QString CliCommandMode::fullHelp() const
"The COLUMNS mode is similar to FIXED mode, except it tries to be smart and make columns with shorter values more thin, "
"while columns with longer values get more space. First to shrink are columns with longest headers (so the header names are to be "
"cut off as first), then columns with the longest values are shrinked, up to the moment when all columns fit into terminal window.\n"
- "ATTENTION! The COLUMNS mode reads all the results from the query at once in order to evaluate column widhts, therefore it is dangerous "
+ "ATTENTION! The COLUMNS mode reads all the results from the query at once in order to evaluate column widths, therefore it is dangerous "
"to use this mode when working with huge result sets. Keep in mind that this mode will load entire result set into memory.\n"
"\n"
"The ROW mode is recommended if you need to see whole values and you don't expect many rows to be displayed, because this mode "
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommandopen.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommandopen.cpp
index fef1737..a7eb004 100644
--- a/SQLiteStudio3/sqlitestudiocli/commands/clicommandopen.cpp
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommandopen.cpp
@@ -10,7 +10,7 @@ void CliCommandOpen::execute()
if (!syntax.isArgumentSet(DB_NAME_OR_FILE) && !cli->getCurrentDb())
{
println(tr("Cannot call %1 when no database is set to be current. Specify current database with %2 command or pass database name to %3.")
- .arg(cmdName("open")).arg(cmdName("use")).arg(cmdName("open")));
+ .arg(cmdName("open"), cmdName("use"), cmdName("open")));
return;
}
@@ -36,7 +36,7 @@ void CliCommandOpen::execute()
{
println(tr("File %1 doesn't exist in %2. Cannot open inexisting database with %3 command. "
"To create a new database, use %4 command.").arg(arg).arg(QDir::currentPath())
- .arg(cmdName("open")).arg(cmdName("add")));
+ .arg(cmdName("open"), cmdName("add")));
return;
}
}
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommandpwd.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommandpwd.cpp
index f96cae4..6646196 100644
--- a/SQLiteStudio3/sqlitestudiocli/commands/clicommandpwd.cpp
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommandpwd.cpp
@@ -19,7 +19,7 @@ QString CliCommandPwd::fullHelp() const
"This is the same as 'pwd' command on Unix systems and 'cd' command without arguments on Windows. "
"It prints current working directory. You can change the current working directory with %1 command "
"and you can also list contents of the current working directory with %2 command."
- ).arg(cmdName("cd")).arg(cmdName("dir"));
+ ).arg(cmdName("cd"), cmdName("dir"));
}
void CliCommandPwd::defineSyntax()
diff --git a/SQLiteStudio3/sqlitestudiocli/commands/clicommandsql.cpp b/SQLiteStudio3/sqlitestudiocli/commands/clicommandsql.cpp
index cb89dfe..e24dbb2 100644
--- a/SQLiteStudio3/sqlitestudiocli/commands/clicommandsql.cpp
+++ b/SQLiteStudio3/sqlitestudiocli/commands/clicommandsql.cpp
@@ -1,8 +1,8 @@
#include "clicommandsql.h"
#include "cli.h"
-#include "parser/ast/sqliteselect.h"
-#include "parser/parser.h"
-#include "parser/parsererror.h"
+//#include "parser/ast/sqliteselect.h"
+//#include "parser/parser.h"
+//#include "parser/parsererror.h"
#include "db/queryexecutor.h"
#include "qio.h"
#include "common/unused.h"
@@ -19,7 +19,7 @@ void CliCommandSql::execute()
println(tr("No working database is set.\n"
"Call %1 command to set working database.\n"
"Call %2 to see list of all databases.")
- .arg(cmdName("use")).arg(cmdName("dblist")));
+ .arg(cmdName("use"), cmdName("dblist")));
return;
}
@@ -92,7 +92,7 @@ void CliCommandSql::printResultsClassic(QueryExecutor* executor, SqlQueryPtr res
int resultColumnCount = executor->getResultColumns().size();
// Columns
- for (const QueryExecutor::ResultColumnPtr& resCol : executor->getResultColumns())
+ for (QueryExecutor::ResultColumnPtr& resCol : executor->getResultColumns())
qOut << resCol->displayName << "|";
qOut << "\n";
@@ -106,7 +106,7 @@ void CliCommandSql::printResultsClassic(QueryExecutor* executor, SqlQueryPtr res
row = results->next();
i = 0;
values = row->valueList().mid(0, resultColumnCount);
- for (QVariant value : values)
+ for (QVariant& value : values)
{
qOut << getValueString(value);
if ((i + 1) < resultColumnCount)
@@ -149,7 +149,7 @@ void CliCommandSql::printResultsFixed(QueryExecutor* executor, SqlQueryPtr resul
// Columns
QStringList columns;
- for (const QueryExecutor::ResultColumnPtr& resCol : executor->getResultColumns())
+ for (QueryExecutor::ResultColumnPtr& resCol : executor->getResultColumns())
columns << resCol->displayName;
printColumnHeader(widths, columns);
@@ -184,7 +184,7 @@ void CliCommandSql::printResultsColumns(QueryExecutor* executor, SqlQueryPtr res
// Get widths of each column in every data row, remember the longest ones
QList<SortedColumnWidth*> columnWidths;
SortedColumnWidth* colWidth = nullptr;
- for (const QueryExecutor::ResultColumnPtr& resCol : resultColumns)
+ for (QueryExecutor::ResultColumnPtr& resCol : resultColumns)
{
colWidth = new SortedColumnWidth();
colWidth->setHeaderWidth(resCol->displayName.length());
@@ -204,7 +204,7 @@ void CliCommandSql::printResultsColumns(QueryExecutor* executor, SqlQueryPtr res
// Calculate width as it would be required to display entire rows
int totalWidth = 0;
- for (SortedColumnWidth* colWd : columnWidths)
+ for (SortedColumnWidth*& colWd : columnWidths)
totalWidth += colWd->getWidth();
totalWidth += (resultColumnsCount - 1); // column separators
@@ -224,12 +224,12 @@ void CliCommandSql::printResultsColumns(QueryExecutor* executor, SqlQueryPtr res
// Printing
QList<int> finalWidths;
- for (SortedColumnWidth* colWd : columnWidths)
+ for (SortedColumnWidth*& colWd : columnWidths)
finalWidths << colWd->getWidth();
printColumnHeader(finalWidths, headerNames);
- for (SqlResultsRowPtr row : allRows)
+ for (SqlResultsRowPtr& row : allRows)
printColumnDataRow(finalWidths, row, resultColumnsCount);
qOut.flush();
@@ -240,14 +240,14 @@ void CliCommandSql::printResultsRowByRow(QueryExecutor* executor, SqlQueryPtr re
// Columns
int resultColumnCount = executor->getResultColumns().size();
int colWidth = 0;
- for (const QueryExecutor::ResultColumnPtr& resCol : executor->getResultColumns())
+ for (QueryExecutor::ResultColumnPtr& resCol : executor->getResultColumns())
{
if (resCol->displayName.length() > colWidth)
colWidth = resCol->displayName.length();
}
QStringList columns;
- for (const QueryExecutor::ResultColumnPtr& resCol : executor->getResultColumns())
+ for (QueryExecutor::ResultColumnPtr& resCol : executor->getResultColumns())
columns << pad(resCol->displayName, -colWidth, ' ');
// Data
@@ -263,7 +263,7 @@ void CliCommandSql::printResultsRowByRow(QueryExecutor* executor, SqlQueryPtr re
i = 0;
rowCntString = " " + rowCntTemplate.arg(rowCnt) + " ";
qOut << center(rowCntString, termWidth - 1, '-') << "\n";
- for (QVariant value : row->valueList().mid(0, resultColumnCount))
+ for (QVariant& value : row->valueList().mid(0, resultColumnCount))
{
qOut << columns[i] + ": " + getValueString(value) << "\n";
i++;
@@ -294,7 +294,7 @@ void CliCommandSql::shrinkColumns(QList<CliCommandSql::SortedColumnWidth*>& colu
sSort(columnWidths);
// See if we can shrink headers only, or we already need to shrink the data
- for (SortedColumnWidth* colWidth : columnWidths)
+ for (SortedColumnWidth*& colWidth : columnWidths)
{
if (colWidth->isHeaderLonger())
{
@@ -381,7 +381,7 @@ void CliCommandSql::printColumnDataRow(const QList<int>& widths, const SqlResult
{
int i = 0;
QStringList line;
- for (const QVariant& value : row->valueList().mid(0, resultColumnCount))
+ for (QVariant& value : row->valueList().mid(0, resultColumnCount))
{
line << pad(getValueString(value).left(widths[i]), widths[i], ' ');
i++;