Skip to content

Commit f7a04fd

Browse files
committed
fix(cli): guard linux-only service and logs commands
2 parents e13683f + 0baf003 commit f7a04fd

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/commands/ServiceCommand.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ namespace vix::commands
7474
return s;
7575
}
7676

77+
#ifdef __linux__
78+
7779
struct HealthResult
7880
{
7981
bool ok{false};
@@ -639,6 +641,8 @@ namespace vix::commands
639641

640642
return rc == 0 ? 0 : 1;
641643
}
644+
645+
#endif // __linux__
642646
}
643647

644648
int ServiceCommand::run(const std::vector<std::string> &args)

src/commands/logs/LogsRunner.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ namespace vix::commands::logs::runner
5151
return std::system(cmd.c_str()) == 0;
5252
}
5353

54+
#ifdef __linux__
55+
5456
std::string grep_errors_command()
5557
{
5658
return "grep -Ei 'error|failed|failure|exception|panic|fatal|critical|timeout|refused|denied'";
@@ -359,21 +361,34 @@ namespace vix::commands::logs::runner
359361

360362
return ok;
361363
}
364+
365+
#endif // __linux__
362366
}
363367

364368
int run(
365369
const LogsConfig &cfg,
366370
const LogsOptions &options)
367371
{
372+
#ifndef __linux__
373+
(void)cfg;
374+
(void)options;
375+
376+
output::error(
377+
std::cerr,
378+
"vix logs is currently supported on Linux only.");
379+
380+
output::fix(
381+
std::cerr,
382+
"run this command on the Linux server that hosts the service");
383+
384+
return 1;
385+
#else
368386
if (!options.json)
369387
output::print_summary(std::cout, cfg, options);
370388

371389
if (options.repeated)
372390
return show_repeated_errors(cfg, options) ? 0 : 1;
373391

374-
if (options.repeated)
375-
return show_repeated_errors(cfg, options) ? 0 : 1;
376-
377392
bool ok = true;
378393

379394
switch (options.target)
@@ -405,5 +420,6 @@ namespace vix::commands::logs::runner
405420

406421
output::ok(std::cout, "logs command completed");
407422
return 0;
423+
#endif
408424
}
409425
}

0 commit comments

Comments
 (0)