1
0
Fork 0

moved shell colors into their own feature

This commit is contained in:
jsteemann 2017-05-23 16:53:43 +02:00
parent fa2441cc96
commit 27a8adf9b8
22 changed files with 217 additions and 155 deletions

View File

@ -31,6 +31,8 @@ WorkMonitorFeature::WorkMonitorFeature(
: ApplicationFeature(server, "WorkMonitor") {
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("ShellColors");
}
void WorkMonitorFeature::start() { WorkMonitor::initialize(); }

View File

@ -36,7 +36,7 @@
#include "ApplicationFeatures/NonceFeature.h"
#include "ApplicationFeatures/PageSizeFeature.h"
#include "ApplicationFeatures/RocksDBOptionFeature.h"
#include "Pregel/PregelFeature.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "ApplicationFeatures/PrivilegeFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/SupervisorFeature.h"
@ -52,6 +52,7 @@
#include "GeneralServer/GeneralServerFeature.h"
#include "Logger/LoggerBufferFeature.h"
#include "Logger/LoggerFeature.h"
#include "Pregel/PregelFeature.h"
#include "ProgramOptions/ProgramOptions.h"
#include "Random/RandomFeature.h"
#include "RestServer/AqlFeature.h"
@ -165,6 +166,7 @@ static int runServer(int argc, char** argv, ArangoGlobalContext &context) {
server.addFeature(new ScriptFeature(&server, &ret));
server.addFeature(new ServerFeature(&server, &ret));
server.addFeature(new ServerIdFeature(&server));
server.addFeature(new ShellColorsFeature(&server));
server.addFeature(new ShutdownFeature(&server, {"UnitTests", "Script"}));
server.addFeature(new SslFeature(&server));
server.addFeature(new StatisticsFeature(&server));

View File

@ -26,6 +26,7 @@
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "ApplicationFeatures/TempFeature.h"
#include "ApplicationFeatures/VersionFeature.h"
#include "Basics/ArangoGlobalContext.h"
@ -59,6 +60,7 @@ int main(int argc, char* argv[]) {
server.addFeature(new ConfigFeature(&server, "arangobench"));
server.addFeature(new LoggerFeature(&server, false));
server.addFeature(new RandomFeature(&server));
server.addFeature(new ShellColorsFeature(&server));
server.addFeature(new ShutdownFeature(&server, {"Bench"}));
server.addFeature(new SslFeature(&server));
server.addFeature(new TempFeature(&server, "arangobench"));

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/VersionFeature.h"
#include "Basics/ArangoGlobalContext.h"
@ -56,6 +57,7 @@ int main(int argc, char* argv[]) {
server.addFeature(new DumpFeature(&server, &ret));
server.addFeature(new LoggerFeature(&server, false));
server.addFeature(new RandomFeature(&server));
server.addFeature(new ShellColorsFeature(&server));
server.addFeature(new ShutdownFeature(&server, {"Dump"}));
server.addFeature(new SslFeature(&server));
server.addFeature(new VersionFeature(&server));

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/TempFeature.h"
#include "ApplicationFeatures/VersionFeature.h"
@ -57,6 +58,7 @@ int main(int argc, char* argv[]) {
server.addFeature(new ExportFeature(&server, &ret));
server.addFeature(new LoggerFeature(&server, false));
server.addFeature(new RandomFeature(&server));
server.addFeature(new ShellColorsFeature(&server));
server.addFeature(new ShutdownFeature(&server, {"Export"}));
server.addFeature(new SslFeature(&server));
server.addFeature(new TempFeature(&server, "arangoexport"));

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/TempFeature.h"
#include "ApplicationFeatures/VersionFeature.h"
@ -57,6 +58,7 @@ int main(int argc, char* argv[]) {
server.addFeature(new ImportFeature(&server, &ret));
server.addFeature(new LoggerFeature(&server, false));
server.addFeature(new RandomFeature(&server));
server.addFeature(new ShellColorsFeature(&server));
server.addFeature(new ShutdownFeature(&server, {"Import"}));
server.addFeature(new SslFeature(&server));
server.addFeature(new TempFeature(&server, "arangoimp"));

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/TempFeature.h"
#include "ApplicationFeatures/VersionFeature.h"
@ -56,6 +57,7 @@ int main(int argc, char* argv[]) {
server.addFeature(new LoggerFeature(&server, false));
server.addFeature(new RandomFeature(&server));
server.addFeature(new RestoreFeature(&server, &ret));
server.addFeature(new ShellColorsFeature(&server));
server.addFeature(new ShutdownFeature(&server, {"Restore"}));
server.addFeature(new SslFeature(&server));
server.addFeature(new TempFeature(&server, "arangorestore"));

View File

@ -22,9 +22,9 @@
#include "ConsoleFeature.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "Basics/StringUtils.h"
#include "Basics/messages.h"
#include "Basics/shell-colors.h"
#include "Basics/terminal-utils.h"
#include "Logger/Logger.h"
#include "ProgramOptions/ProgramOptions.h"
@ -504,9 +504,9 @@ ConsoleFeature::Prompt ConsoleFeature::buildPrompt(ClientFeature* client) {
if (_supportsColors && _colors) {
if (_promptError) {
colored = TRI_SHELL_COLOR_BOLD_RED + result + TRI_SHELL_COLOR_RESET;
colored = ShellColorsFeature::SHELL_COLOR_BOLD_RED + result + ShellColorsFeature::SHELL_COLOR_RESET;
} else {
colored = TRI_SHELL_COLOR_BOLD_GREEN + result + TRI_SHELL_COLOR_RESET;
colored = ShellColorsFeature::SHELL_COLOR_BOLD_GREEN + result + ShellColorsFeature::SHELL_COLOR_RESET;
}
} else {
colored = result;

View File

@ -22,12 +22,12 @@
#include "V8ShellFeature.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "ApplicationFeatures/V8PlatformFeature.h"
#include "Basics/ArangoGlobalContext.h"
#include "Basics/FileUtils.h"
#include "Basics/StringUtils.h"
#include "Basics/Utf8Helper.h"
#include "Basics/shell-colors.h"
#include "Logger/Logger.h"
#include "ProgramOptions/ProgramOptions.h"
#include "ProgramOptions/Section.h"
@ -192,9 +192,9 @@ bool V8ShellFeature::printHello(V8ClientConnection* v8connection) {
// http://www.network-science.de/ascii/ Font: ogre
if (!_console->quiet()) {
std::string g = TRI_SHELL_COLOR_GREEN;
std::string r = TRI_SHELL_COLOR_RED;
std::string z = TRI_SHELL_COLOR_RESET;
std::string g = ShellColorsFeature::SHELL_COLOR_GREEN;
std::string r = ShellColorsFeature::SHELL_COLOR_RED;
std::string z = ShellColorsFeature::SHELL_COLOR_RESET;
if (!_console->colors()) {
g = "";

View File

@ -26,6 +26,7 @@
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/LanguageFeature.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/TempFeature.h"
#include "ApplicationFeatures/V8PlatformFeature.h"
@ -65,6 +66,7 @@ int main(int argc, char* argv[]) {
server.addFeature(new LanguageFeature(&server));
server.addFeature(new LoggerFeature(&server, false));
server.addFeature(new RandomFeature(&server));
server.addFeature(new ShellColorsFeature(&server));
server.addFeature(new ShellFeature(&server, &ret));
server.addFeature(new ShutdownFeature(&server, {"Shell"}));
server.addFeature(new SslFeature(&server));

View File

@ -25,6 +25,7 @@
#include "Basics/directories.h"
#include "ApplicationFeatures/ConfigFeature.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "ApplicationFeatures/ShutdownFeature.h"
#include "ApplicationFeatures/VersionFeature.h"
#include "Basics/ArangoGlobalContext.h"
@ -52,6 +53,7 @@ int main(int argc, char* argv[]) {
server.addFeature(new ConfigFeature(&server, "arangovpack"));
server.addFeature(new LoggerFeature(&server, false));
server.addFeature(new RandomFeature(&server));
server.addFeature(new ShellColorsFeature(&server));
server.addFeature(new ShutdownFeature(&server, {"VPack"}));
server.addFeature(new VPackFeature(&server, &ret));
server.addFeature(new VersionFeature(&server));

View File

@ -49,6 +49,7 @@ ConfigFeature::ConfigFeature(application_features::ApplicationServer* server,
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("Logger");
startsAfter("ShellColors");
}
void ConfigFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {

View File

@ -0,0 +1,88 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2016 ArangoDB GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#include "ShellColorsFeature.h"
using namespace arangodb;
using namespace arangodb::basics;
namespace {
static char const* NoColor = "";
}
char const* ShellColorsFeature::SHELL_COLOR_RED = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BOLD_RED = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_GREEN = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BOLD_GREEN = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BLUE = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BOLD_BLUE = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_YELLOW = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BOLD_YELLOW = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_WHITE = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BOLD_WHITE = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BLACK = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BOLD_BLACK = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_CYAN = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BOLD_CYAN = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_MAGENTA = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BOLD_MAGENTA = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BLINK = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_BRIGHT = NoColor;
char const* ShellColorsFeature::SHELL_COLOR_RESET = NoColor;
ShellColorsFeature::ShellColorsFeature(
application_features::ApplicationServer* server)
: ApplicationFeature(server, "ShellColors") {
setOptional(false);
requiresElevatedPrivileges(false);
}
void ShellColorsFeature::prepare() {
if (useColors()) {
SHELL_COLOR_RED = "\x1b[31m";
SHELL_COLOR_BOLD_RED = "\x1b[1;31m";
SHELL_COLOR_GREEN = "\x1b[32m";
SHELL_COLOR_BOLD_GREEN = "\x1b[1;32m";
SHELL_COLOR_BLUE = "\x1b[34m";
SHELL_COLOR_BOLD_BLUE = "\x1b[1;34m";
SHELL_COLOR_YELLOW = "\x1b[33m";
SHELL_COLOR_BOLD_YELLOW = "\x1b[1;33m";
SHELL_COLOR_WHITE = "\x1b[37m";
SHELL_COLOR_BOLD_WHITE = "\x1b[1;37m";
SHELL_COLOR_BLACK = "\x1b[30m";
SHELL_COLOR_BOLD_BLACK = "\x1b[1;30m";
SHELL_COLOR_CYAN = "\x1b[36m";
SHELL_COLOR_BOLD_CYAN = "\x1b[1;36m";
SHELL_COLOR_MAGENTA = "\x1b[35m";
SHELL_COLOR_BOLD_MAGENTA = "\x1b[1;35m";
SHELL_COLOR_BLINK = "\x1b[5m";
SHELL_COLOR_BRIGHT = "\x1b[1m";
SHELL_COLOR_RESET = "\x1b[0m";
}
}
bool ShellColorsFeature::useColors() {
#ifndef _WIN32
return true;
#endif
return false;
}

View File

@ -0,0 +1,62 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2016 ArangoDB GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGODB_APPLICATION_FEATURES_SHELL_COLORS_FEATURE_H
#define ARANGODB_APPLICATION_FEATURES_SHELL_COLORS_FEATURE_H 1
#include "ApplicationFeatures/ApplicationFeature.h"
namespace arangodb {
class ShellColorsFeature final : public application_features::ApplicationFeature {
public:
explicit ShellColorsFeature(application_features::ApplicationServer* server);
public:
void prepare() override final;
private:
bool useColors();
public:
static char const* SHELL_COLOR_RED;
static char const* SHELL_COLOR_BOLD_RED;
static char const* SHELL_COLOR_GREEN;
static char const* SHELL_COLOR_BOLD_GREEN;
static char const* SHELL_COLOR_BLUE;
static char const* SHELL_COLOR_BOLD_BLUE;
static char const* SHELL_COLOR_YELLOW;
static char const* SHELL_COLOR_BOLD_YELLOW;
static char const* SHELL_COLOR_WHITE;
static char const* SHELL_COLOR_BOLD_WHITE;
static char const* SHELL_COLOR_BLACK;
static char const* SHELL_COLOR_BOLD_BLACK;
static char const* SHELL_COLOR_CYAN;
static char const* SHELL_COLOR_BOLD_CYAN;
static char const* SHELL_COLOR_MAGENTA;
static char const* SHELL_COLOR_BOLD_MAGENTA;
static char const* SHELL_COLOR_BLINK;
static char const* SHELL_COLOR_BRIGHT;
static char const* SHELL_COLOR_RESET;
};
}
#endif

View File

@ -36,6 +36,8 @@ VersionFeature::VersionFeature(application_features::ApplicationServer* server)
_printVersion(false) {
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("ShellColors");
}
void VersionFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {

View File

@ -1,115 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Jan Steemann
////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGODB_BASICS_SHELL__COLORS_H
#define ARANGODB_BASICS_SHELL__COLORS_H 1
#ifdef _WIN32
/// @brief disable escape sequences on Windows
/// because MS-DOS does not support them
/// the proper fix for this would be to define or
/// not define the color codes depending on the
/// type of terminal used
#define TRI_SHELL_COLOR_RED ""
#define TRI_SHELL_COLOR_BOLD_RED ""
#define TRI_SHELL_COLOR_GREEN ""
#define TRI_SHELL_COLOR_BOLD_GREEN ""
#define TRI_SHELL_COLOR_BLUE ""
#define TRI_SHELL_COLOR_BOLD_BLUE ""
#define TRI_SHELL_COLOR_YELLOW ""
#define TRI_SHELL_COLOR_BOLD_YELLOW ""
#define TRI_SHELL_COLOR_WHITE ""
#define TRI_SHELL_COLOR_BOLD_WHITE ""
#define TRI_SHELL_COLOR_BLACK ""
#define TRI_SHELL_COLOR_BOLD_BLACK ""
#define TRI_SHELL_COLOR_CYAN ""
#define TRI_SHELL_COLOR_BOLD_CYAN ""
#define TRI_SHELL_COLOR_MAGENTA ""
#define TRI_SHELL_COLOR_BOLD_MAGENTA ""
#define TRI_SHELL_COLOR_BLINK ""
#define TRI_SHELL_COLOR_BRIGHT ""
#define TRI_SHELL_COLOR_RESET ""
#else
/// @brief color red
#define TRI_SHELL_COLOR_RED "\x1b[31m"
/// @brief color bold red
#define TRI_SHELL_COLOR_BOLD_RED "\x1b[1;31m"
/// @brief color green
#define TRI_SHELL_COLOR_GREEN "\x1b[32m"
/// @brief color bold green
#define TRI_SHELL_COLOR_BOLD_GREEN "\x1b[1;32m"
/// @brief color blue
#define TRI_SHELL_COLOR_BLUE "\x1b[34m"
/// @brief color bold blue
#define TRI_SHELL_COLOR_BOLD_BLUE "\x1b[1;34m"
/// @brief color yellow
#define TRI_SHELL_COLOR_YELLOW "\x1b[33m"
/// @brief color yellow
#define TRI_SHELL_COLOR_BOLD_YELLOW "\x1b[1;33m"
/// @brief color white
#define TRI_SHELL_COLOR_WHITE "\x1b[37m"
/// @brief color bold white
#define TRI_SHELL_COLOR_BOLD_WHITE "\x1b[1;37m"
/// @brief color black
#define TRI_SHELL_COLOR_BLACK "\x1b[30m"
/// @brief color bold black
#define TRI_SHELL_COLOR_BOLD_BLACK "\x1b[1;30m"
/// @brief color cyan
#define TRI_SHELL_COLOR_CYAN "\x1b[36m"
/// @brief color bold cyan
#define TRI_SHELL_COLOR_BOLD_CYAN "\x1b[1;36m"
/// @brief color magenta
#define TRI_SHELL_COLOR_MAGENTA "\x1b[35m"
/// @brief color bold magenta
#define TRI_SHELL_COLOR_BOLD_MAGENTA "\x1b[1;35m"
/// @brief color blink
#define TRI_SHELL_COLOR_BLINK "\x1b[5m"
/// @brief color bright
#define TRI_SHELL_COLOR_BRIGHT "\x1b[1m"
/// @brief color reset
#define TRI_SHELL_COLOR_RESET "\x1b[0m"
#endif
#endif

View File

@ -117,6 +117,7 @@ add_library(${LIB_ARANGO} STATIC
ApplicationFeatures/PageSizeFeature.cpp
ApplicationFeatures/PrivilegeFeature.cpp
ApplicationFeatures/RocksDBOptionFeature.cpp
ApplicationFeatures/ShellColorsFeature.cpp
ApplicationFeatures/ShutdownFeature.cpp
ApplicationFeatures/TempFeature.cpp
ApplicationFeatures/V8PlatformFeature.cpp

View File

@ -24,9 +24,9 @@
#include "LogAppender.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "Basics/MutexLocker.h"
#include "Basics/StringUtils.h"
#include "Basics/shell-colors.h"
#include "Logger/LogAppenderFile.h"
#include "Logger/LogAppenderSyslog.h"
#include "Logger/LogAppenderTty.h"
@ -224,11 +224,9 @@ void LogAppender::log(LogMessage* message) {
void LogAppender::writeStderr(LogLevel level, std::string const& msg) {
if (level == LogLevel::FATAL || level == LogLevel::ERR) {
fprintf(stderr, TRI_SHELL_COLOR_RED "%s" TRI_SHELL_COLOR_RESET "\n",
msg.c_str());
fprintf(stderr, "%s%s%s\n", ShellColorsFeature::SHELL_COLOR_RED, msg.c_str(), ShellColorsFeature::SHELL_COLOR_RESET);
} else if (level == LogLevel::WARN) {
fprintf(stderr, TRI_SHELL_COLOR_YELLOW "%s" TRI_SHELL_COLOR_RESET "\n",
msg.c_str());
fprintf(stderr, "%s%s%s\n", ShellColorsFeature::SHELL_COLOR_YELLOW, msg.c_str(), ShellColorsFeature::SHELL_COLOR_RESET);
} else {
fprintf(stderr, "%s\n", msg.c_str());
}

View File

@ -43,6 +43,7 @@ LoggerFeature::LoggerFeature(application_features::ApplicationServer* server,
setOptional(false);
requiresElevatedPrivileges(false);
startsAfter("ShellColors");
startsAfter("Version");
if (threaded) {

View File

@ -21,8 +21,8 @@
////////////////////////////////////////////////////////////////////////////////
#include "ProgramOptions.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "Basics/levenshtein.h"
#include "Basics/shell-colors.h"
#include "Basics/terminal-utils.h"
#include "ProgramOptions/Option.h"
#include "ProgramOptions/Section.h"
@ -98,8 +98,8 @@ void ProgramOptions::printSectionsHelp() const {
char const* colorEnd;
if (isatty(STDOUT_FILENO)) {
colorStart = TRI_SHELL_COLOR_BRIGHT;
colorEnd = TRI_SHELL_COLOR_RESET;
colorStart = ShellColorsFeature::SHELL_COLOR_BRIGHT;
colorEnd = ShellColorsFeature::SHELL_COLOR_RESET;
} else {
colorStart = colorEnd = "";
}
@ -287,8 +287,8 @@ bool ProgramOptions::unknownOption(std::string const& name) {
char const* colorEnd;
if (isatty(STDERR_FILENO)) {
colorStart = TRI_SHELL_COLOR_BRIGHT;
colorEnd = TRI_SHELL_COLOR_RESET;
colorStart = ShellColorsFeature::SHELL_COLOR_BRIGHT;
colorEnd = ShellColorsFeature::SHELL_COLOR_RESET;
} else {
colorStart = colorEnd = "";
}

View File

@ -21,7 +21,7 @@
////////////////////////////////////////////////////////////////////////////////
#include "Section.h"
#include "Basics/shell-colors.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "ProgramOptions/Option.h"
#include <iostream>
@ -51,7 +51,7 @@ void Section::printHelp(std::string const& search, size_t tw, size_t ow, bool co
}
if (colors) {
std::cout << "Section '" << TRI_SHELL_COLOR_BRIGHT << displayName() << TRI_SHELL_COLOR_RESET << "' (" << description << ")"
std::cout << "Section '" << ShellColorsFeature::SHELL_COLOR_BRIGHT << displayName() << ShellColorsFeature::SHELL_COLOR_RESET << "' (" << description << ")"
<< std::endl;
} else {
std::cout << "Section '" << displayName() << "' (" << description << ")"

View File

@ -23,10 +23,10 @@
#include "v8-shell.h"
#include "ApplicationFeatures/ShellColorsFeature.h"
#include "Basics/csv.h"
#include "Basics/Exceptions.h"
#include "Basics/OpenFilesTracker.h"
#include "Basics/shell-colors.h"
#include "Basics/tri-strings.h"
#include "V8/v8-globals.h"
#include "V8/v8-conv.h"
@ -35,6 +35,10 @@
#include <fstream>
using namespace arangodb;
namespace {
////////////////////////////////////////////////////////////////////////////////
/// @brief begins a new CSV line
////////////////////////////////////////////////////////////////////////////////
@ -82,6 +86,8 @@ static void ProcessCsvEnd(TRI_csv_parser_t* parser, char const* field, size_t,
(*cb)->Call(*cb, 2, args);
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief processes a CSV file
///
@ -326,97 +332,97 @@ void TRI_InitV8Shell(v8::Isolate* isolate, v8::Handle<v8::Context> context) {
v8::Handle<v8::Object> colors = v8::Object::New(isolate);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_RED"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_RED)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_RED)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BOLD_RED"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BOLD_RED)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BOLD_RED)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_GREEN"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_GREEN)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_GREEN)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BOLD_GREEN"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BOLD_GREEN)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BOLD_GREEN)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BLUE"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BLUE)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BLUE)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BOLD_BLUE"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BOLD_BLUE)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BOLD_BLUE)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_YELLOW"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_YELLOW)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_YELLOW)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BOLD_YELLOW"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BOLD_YELLOW)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BOLD_YELLOW)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_WHITE"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_WHITE)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_WHITE)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BOLD_WHITE"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BOLD_WHITE)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BOLD_WHITE)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_CYAN"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_CYAN)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_CYAN)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BOLD_CYAN"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BOLD_CYAN)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BOLD_CYAN)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_MAGENTA"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_MAGENTA)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_MAGENTA)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BOLD_MAGENTA"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BOLD_MAGENTA)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BOLD_MAGENTA)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BLACK"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BLACK)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BLACK)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BOLD_BLACK"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BOLD_BLACK)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BOLD_BLACK)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BLINK"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BLINK)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BLINK)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_BRIGHT"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_BRIGHT)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_BRIGHT)
: v8::String::Empty(isolate),
v8::ReadOnly);
colors->ForceSet(TRI_V8_ASCII_STRING("COLOR_RESET"),
isTty ? TRI_V8_ASCII_STRING(TRI_SHELL_COLOR_RESET)
isTty ? TRI_V8_ASCII_STRING(ShellColorsFeature::SHELL_COLOR_RESET)
: v8::String::Empty(isolate),
v8::ReadOnly);