Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ekam-client -f #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/ekam/ConsoleDashboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,22 @@ void ConsoleDashboard::TaskImpl::setState(TaskState state) {
if (silence != SILENT) dashboard->runningTasks.push_back(this);
break;
case DONE:
writeFinalLog(DONE_COLOR, " ");
if (!dashboard->onlyPrintFailures) {
writeFinalLog(DONE_COLOR, " ");
}
break;
case PASSED:
writeFinalLog(PASSED_COLOR, "✔");
if (!dashboard->onlyPrintFailures) {
writeFinalLog(PASSED_COLOR, "✔");
}
break;
case FAILED:
writeFinalLog(FAILED_COLOR, "✘");
break;
case BLOCKED:
// Don't display.
if (dashboard->onlyPrintFailures) {
writeFinalLog(BLOCKED_COLOR, "✘?");
}
break;
}

Expand Down Expand Up @@ -320,11 +326,13 @@ const char* const ConsoleDashboard::ANSI_CLEAR_BELOW_CURSOR = "\033[0J";
const ConsoleDashboard::Color ConsoleDashboard::DONE_COLOR = BRIGHT_BLUE;
const ConsoleDashboard::Color ConsoleDashboard::PASSED_COLOR = BRIGHT_GREEN;
const ConsoleDashboard::Color ConsoleDashboard::FAILED_COLOR = BRIGHT_RED;
const ConsoleDashboard::Color ConsoleDashboard::BLOCKED_COLOR = RED;
const ConsoleDashboard::Color ConsoleDashboard::RUNNING_COLOR = BRIGHT_FUCHSIA;

ConsoleDashboard::ConsoleDashboard(FILE* output, int maxDisplayedLogLines)
ConsoleDashboard::ConsoleDashboard(FILE* output, int maxDisplayedLogLines, bool onlyPrintFailures)
: fd(fileno(output)), out(output), maxDisplayedLogLines(maxDisplayedLogLines),
runningTasksLineCount(0), lastDebugMessageCount(DebugMessage::getMessageCount()) {}
onlyPrintFailures(onlyPrintFailures), runningTasksLineCount(0),
lastDebugMessageCount(DebugMessage::getMessageCount()) {}
ConsoleDashboard::~ConsoleDashboard() {}

OwnedPtr<Dashboard::Task> ConsoleDashboard::beginTask(
Expand Down
4 changes: 3 additions & 1 deletion src/ekam/ConsoleDashboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace ekam {

class ConsoleDashboard : public Dashboard {
public:
ConsoleDashboard(FILE* output, int maxDisplayedLogLines);
ConsoleDashboard(FILE* output, int maxDisplayedLogLines, bool onlyPrintFailures = false);
~ConsoleDashboard();

// implements Dashboard ----------------------------------------------------------------
Expand All @@ -38,6 +38,7 @@ class ConsoleDashboard : public Dashboard {
int fd;
FILE* out;
int maxDisplayedLogLines;
bool onlyPrintFailures;

std::vector<TaskImpl*> runningTasks;
int runningTasksLineCount;
Expand Down Expand Up @@ -71,6 +72,7 @@ class ConsoleDashboard : public Dashboard {
static const Color PASSED_COLOR;
static const Color FAILED_COLOR;
static const Color RUNNING_COLOR;
static const Color BLOCKED_COLOR;

void clearRunning();
void drawRunning();
Expand Down
11 changes: 9 additions & 2 deletions src/ekam/ekam-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ Dashboard::TaskState toDashboardState(proto::TaskUpdate::State state) {

int main(int argc, char* argv[]) {
int maxDisplayedLogLines = 30;

bool onlyPrintFailures = false;

for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-l") == 0) {
char* endptr;
Expand All @@ -89,13 +90,19 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "Expected number after -l.\n");
return 1;
}
} else if (strcmp(argv[i], "-f") == 0) {
onlyPrintFailures = true;
} else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
printf(
"usage: nc <host> <port> | %s [-l <count>]\n"
"\n"
"Connect to Ekam process at <host> <port> and display build status.\n"
"\n"
"options:\n"
" -f Only print failures, and print failures early. Some failures\n"
" will be due to missing dependencies, and will be marked using\n"
" with ✘? and a darker shade of red.\n"
"\n"
" -l <count> Set max number of log lines to display per action. This is\n"
" kept relatively short by default because it makes the build\n"
" output noisy, but you may need to increase it if you need\n"
Expand All @@ -117,7 +124,7 @@ int main(int argc, char* argv[]) {
printf("Project root: %s\n", header.getProjectRoot().cStr());
}

ConsoleDashboard dashboard(stdout, maxDisplayedLogLines);
ConsoleDashboard dashboard(stdout, maxDisplayedLogLines, onlyPrintFailures);
OwnedPtrMap<int, Dashboard::Task> tasks;

while (bufferedInput.tryGetReadBuffer() != nullptr) {
Expand Down