Skip to content

Commit f3983c7

Browse files
committed
aquarium: Preliminary check for if executable exists
1 parent d87d058 commit f3983c7

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/class/aquarium.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ static int instantiate(flamingo_val_t* inst, flamingo_arg_list_t* args) {
219219
return -1;
220220
}
221221

222+
if (!has_aquarium_cli()) {
223+
return -1;
224+
}
225+
222226
// Create state object.
223227

224228
aquarium_state_t* const state = malloc(sizeof *state);

src/class/aquarium_builder.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ static int instantiate(flamingo_val_t* inst, flamingo_arg_list_t* args) {
301301
return -1;
302302
}
303303

304+
if (!has_aquarium_cli()) {
305+
return -1;
306+
}
307+
304308
// Create state object.
305309

306310
state_t* const state = malloc(sizeof *state);

src/class/aquarium_common.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#pragma once
55

6+
#include <cmd.h>
7+
#include <logging.h>
8+
69
typedef struct {
710
char* template;
811
char* kernel;
@@ -12,4 +15,11 @@ typedef struct {
1215
char* cookie;
1316
} aquarium_state_t;
1417

15-
// TODO Put the preliminary aquarium check in here as a simple inline function.
18+
static bool has_aquarium_cli(void) {
19+
if (!cmd_exists("aquarium")) {
20+
LOG_FATAL("Couldn't find 'aquarium' executable in PATH. The aquarium tool is something you must install separately.");
21+
return false;
22+
}
23+
24+
return true;
25+
}

0 commit comments

Comments
 (0)