refactor(cli): Extract FAIL macro to command.h

This commit is contained in:
Rachel 2024-12-31 11:50:05 -08:00
parent f2583dbf6e
commit a2e14a20b6
6 changed files with 13 additions and 9 deletions

View File

@ -18,6 +18,15 @@
#include <stdbool.h>
// Standard failure macro. `fail` should be implemented for all commands
// as an end-state where any potentially-allocated memory is freed and the
// routine returns EXIT_FAILURE.
#define FAIL(msgfmt, ...) \
{ \
fprintf(stderr, msgfmt, __VA_ARGS__); \
goto fail; \
}
struct command {
const char *abbrev;
const char *name;

View File

@ -19,15 +19,6 @@
#include <stdbool.h>
#include <stddef.h>
// Standard failure macro. `fail` should be implemented for all commands
// as an end-state where any potentially-allocated memory is freed and the
// routine returns EXIT_FAILURE.
#define FAIL(msgfmt, ...) \
{ \
fprintf(stderr, msgfmt, __VA_ARGS__); \
goto fail; \
}
bool match_either(const char *s, const char *a, const char *b);
char *basename(const char *path);

View File

@ -28,6 +28,7 @@
#include "defs/narc.h"
#include "defs/vfs.h"
#include "command.h"
#include "strbuild.h"
#include "strutil.h"
#include "strvec.h"

View File

@ -25,6 +25,7 @@
#include "defs/error.h"
#include "defs/vfs.h"
#include "command.h"
#include "strutil.h"
// clang-format off

View File

@ -26,6 +26,7 @@
#include "defs/fntb.h"
#include "defs/vfs.h"
#include "command.h"
#include "strutil.h"
// clang-format off

View File

@ -23,6 +23,7 @@
#include "api/files.h"
#include "api/load.h"
#include "command.h"
#include "strutil.h"
// clang-format off