Rename once more to `bootstrap`.

pull/9/head
Joshua Potter 2023-11-23 11:02:40 -07:00
parent 63e5acc91f
commit bdbd942e9b
10 changed files with 33 additions and 33 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
.cache/
.direnv/
compile_commands.json
spec
bootstrap
test/runner

View File

@ -1,4 +1,4 @@
BUILD=clang -Og -g -I include src/*.c main.c -o spec
BUILD=clang -Og -g -I include src/*.c main.c -o bootstrap
all: build bear

View File

@ -1,12 +1,12 @@
# spec
# bootstrap
CLI utility for initializing projects in reproducible ways.
## Overview
Within the `specs` directory exists so-called *specs*. A spec is a directory
containing a `spec.json` file and a `run.sh` file. The former is configured like
so:
containing an optional `spec.json` file and a `run.sh` file. The former is
configured like so:
```spec.json
{
@ -15,9 +15,9 @@ so:
```
The keys of this top-level JSON object correspond to the parameters that are
prompted by the `spec init` curses interface. The value is used to determine
what kind of prompt `spec` provides for the given question. Possible value types
include:
prompted by the `bootstrap init` curses interface. The value is used to
determine what kind of prompt `bootstrap` provides for the given question.
Possible value types include:
* `[...]` (list)
* This indicates a select option prompt. The user chooses amongst the values

View File

@ -31,7 +31,7 @@
ncurses
];
shellHook = ''
export SPEC_ROOT_DIR="${./specs}"
export BOOTSTRAP_ROOT_DIR="${./specs}"
'';
};
}

View File

@ -1,14 +1,14 @@
#ifndef _SPEC_CONFIG_H
#define _SPEC_CONFIG_H
#ifndef _BOOTSTRAP_CONFIG_H
#define _BOOTSTRAP_CONFIG_H
struct Config {
// The directory the `spec` command was run from.
// The directory the `bootstrap` command was run from.
// OWNERSHIP: Does not own this pointer.
const char *cwd;
// The root directory housing our specs.
// OWNERSHIP: Does not own this pointer.
const char *root_dir;
// The name of the spec we want to load.
// The name of the spec we want to bootstrap.
// OWNERSHIP: Does not own this pointer.
const char *target;
};
@ -16,8 +16,8 @@ struct Config {
enum ConfigError {
// Indicates the $CWD could not be retrieved.
CE_ENV_CWD_INVALID = 1,
// Indicates the `$SPEC_ROOT_DIR` environment variable is empty.
CE_ENV_SPEC_ROOT_DIR_INVALID,
// Indicates the $BOOTSTRAP_ROOT_DIR environment variable is empty.
CE_ENV_ROOT_DIR_INVALID,
// Indicates the target argument is invalid.
CE_TARGET_INVALID,
};
@ -31,4 +31,4 @@ enum ConfigError config_load(
void config_free(struct Config *config);
#endif /* _SPEC_CONFIG_H */
#endif /* BOOTSTRAP_CONFIG_H */

View File

@ -1,5 +1,5 @@
#ifndef _SPEC_DYN_ARRAY_H
#define _SPEC_DYN_ARRAY_H
#ifndef _BOOTSTRAP_DYN_ARRAY_H
#define _BOOTSTRAP_DYN_ARRAY_H
#include <stdlib.h>
@ -19,4 +19,4 @@ void dyn_array_push(struct DynArray *a, void *item);
void dyn_array_free(struct DynArray *a);
#endif /* _SPEC_DYN_ARRAY_H */
#endif /* _BOOTSTRAP_DYN_ARRAY_H */

10
main.c
View File

@ -5,18 +5,18 @@
#include "config.h"
#include "dyn_array.h"
const char *ENV_SPEC_ROOT_DIR = "SPEC_ROOT_DIR";
const char *ENV_BOOTSTRAP_ROOT_DIR = "BOOTSTRAP_ROOT_DIR";
int main(int argc, char **argv) {
int num = 0;
if (argc != 2) {
fprintf(stderr, "Usage: gen-flake <spec>\n");
fprintf(stderr, "Usage: bootstrap <spec>\n");
exit(EXIT_FAILURE);
}
const char *cwd = getcwd(0, 0);
const char *root_dir = getenv(ENV_SPEC_ROOT_DIR);
const char *root_dir = getenv(ENV_BOOTSTRAP_ROOT_DIR);
const char *target = argv[1];
struct Config *config = 0;
@ -24,8 +24,8 @@ int main(int argc, char **argv) {
case CE_ENV_CWD_INVALID:
fprintf(stderr, "Could not retrieve the $CWD value.");
exit(EXIT_FAILURE);
case CE_ENV_SPEC_ROOT_DIR_INVALID:
fprintf(stderr, "Must specify $SPEC_ROOT_DIR environment variable.");
case CE_ENV_ROOT_DIR_INVALID:
fprintf(stderr, "Must specify $BOOTSTRAP_ROOT_DIR environment variable.");
exit(EXIT_FAILURE);
case CE_TARGET_INVALID:
fprintf(stderr, "Target spec `%s` is invalid.", argv[1]);

View File

@ -13,7 +13,7 @@ enum ConfigError config_load(
return CE_ENV_CWD_INVALID;
}
if (root_dir == 0) {
return CE_ENV_SPEC_ROOT_DIR_INVALID;
return CE_ENV_ROOT_DIR_INVALID;
}
if (target == 0) {
return CE_TARGET_INVALID;

View File

@ -1,10 +1,10 @@
#ifndef _SPEC_TEST_CONFIG
#define _SPEC_TEST_CONFIG
#ifndef _BOOTSTRAP_TEST_CONFIG
#define _BOOTSTRAP_TEST_CONFIG
#include "config.h"
#include "sput.h"
static const char *SAMPLE_CWD = "/home/jrpotter/Documents/spec";
static const char *SAMPLE_CWD = "/home/jrpotter/Documents/bootstrap";
static const char *SAMPLE_ROOT_DIR = "/usr/local/share/specs";
static const char *SAMPLE_TARGET = "example-target";
@ -18,7 +18,7 @@ static void test_config_load_cwd_invalid() {
static void test_config_load_root_dir_invalid() {
struct Config *config = 0;
enum ConfigError retval = config_load(SAMPLE_CWD, 0, SAMPLE_TARGET, &config);
sput_fail_unless(retval == CE_ENV_SPEC_ROOT_DIR_INVALID, "root_dir == 0");
sput_fail_unless(retval == CE_ENV_ROOT_DIR_INVALID, "root_dir == 0");
}
static void test_config_load_target_invalid() {
@ -42,4 +42,4 @@ static void test_config_load_success() {
config_free(config);
}
#endif /* _SPEC_TEST_CONFIG */
#endif /* _BOOTSTRAP_TEST_CONFIG */

View File

@ -1,5 +1,5 @@
#ifndef _SPEC_TEST_DYN_ARRAY
#define _SPEC_TEST_DYN_ARRAY
#ifndef _BOOTSTRAP_TEST_DYN_ARRAY
#define _BOOTSTRAP_TEST_DYN_ARRAY
#include "dyn_array.h"
#include "sput.h"
@ -44,4 +44,4 @@ static void test_dyn_array_nonzero_capacity() {
dyn_array_free(a);
}
#endif /* _SPEC_TEST_DYN_ARRAY */
#endif /* _BOOTSTRAP_TEST_DYN_ARRAY */