1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 working 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."
).arg(cmdName("cd"), cmdName("pwd"), cmdName("ls"));
}
void CliCommandCd::defineSyntax()
{
syntax.setName("cd");
syntax.addArgument(DIR_PATH, tr("path", "CLI command syntax"));
}
|