From 685a16155504831c8b5fdb9a4d0a955b21c807bf Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 2 Aug 2017 12:12:07 -0600 Subject: Info command to print some default information --- sinksh/CMakeLists.txt | 1 + sinksh/syntax_modules/sink_info.cpp | 49 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 sinksh/syntax_modules/sink_info.cpp diff --git a/sinksh/CMakeLists.txt b/sinksh/CMakeLists.txt index bc487c1..cd12c16 100644 --- a/sinksh/CMakeLists.txt +++ b/sinksh/CMakeLists.txt @@ -19,6 +19,7 @@ set(sink_cli_SRCS syntax_modules/sink_inspect.cpp syntax_modules/sink_drop.cpp syntax_modules/sink_upgrade.cpp + syntax_modules/sink_info.cpp sinksh_utils.cpp repl/repl.cpp repl/replStates.cpp diff --git a/sinksh/syntax_modules/sink_info.cpp b/sinksh/syntax_modules/sink_info.cpp new file mode 100644 index 0000000..5f535eb --- /dev/null +++ b/sinksh/syntax_modules/sink_info.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2017 Christian Mollekopf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include // tr() + +#include "common/definitions.h" + +#include "sinksh_utils.h" +#include "state.h" +#include "syntaxtree.h" + +namespace SinkInfo +{ + +bool info(const QStringList &args, State &state) +{ + state.printLine(QString("Storage location: %1").arg(Sink::storageLocation())); + state.printLine(QString("Data location: %1").arg(Sink::dataLocation())); + state.printLine(QString("Config location: %1").arg(Sink::configLocation())); + state.printLine(QString("Temporary file location: %1").arg(Sink::temporaryFileLocation())); + state.printLine(QString("Resource storage location: %1").arg(Sink::resourceStorageLocation("$RESOURCE"))); + return false; +} + +Syntax::List syntax() +{ + return Syntax::List() << Syntax{"info", QObject::tr("Shows general system info"), &SinkInfo::info, Syntax::NotInteractive}; +} + +REGISTER_SYNTAX(SinkInfo) + +} -- cgit v1.2.3