summaryrefslogtreecommitdiffstats
path: root/src/cmd.h
blob: 205f6a7fb7dcd74fd27d0e0306e5f168e77e49e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include <wchar.h>

#include <stdbool.h>

#define CMD_SET_STATUS(...) do { \
		free(cmd_status); \
		cmd_status = aprintf(__VA_ARGS__); \
	} while (0)

typedef bool (*cmd_func)(const wchar_t *args);

struct cmd {
	const wchar_t *name;
	cmd_func func;
};

void cmd_init(void);
void cmd_deinit(void);

bool cmd_run(const wchar_t *name);
bool cmd_rerun(void);

const struct cmd *cmd_get(const wchar_t *name);
const struct cmd *cmd_find(const wchar_t *name);

extern const struct cmd commands[];
extern const size_t command_count;