Rename once more to `bootstrap`.
parent
63e5acc91f
commit
bdbd942e9b
|
@ -1,5 +1,5 @@
|
||||||
.cache/
|
.cache/
|
||||||
.direnv/
|
.direnv/
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
spec
|
bootstrap
|
||||||
test/runner
|
test/runner
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -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
|
all: build bear
|
||||||
|
|
||||||
|
|
12
README.md
12
README.md
|
@ -1,12 +1,12 @@
|
||||||
# spec
|
# bootstrap
|
||||||
|
|
||||||
CLI utility for initializing projects in reproducible ways.
|
CLI utility for initializing projects in reproducible ways.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Within the `specs` directory exists so-called *specs*. A spec is a directory
|
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
|
containing an optional `spec.json` file and a `run.sh` file. The former is
|
||||||
so:
|
configured like so:
|
||||||
|
|
||||||
```spec.json
|
```spec.json
|
||||||
{
|
{
|
||||||
|
@ -15,9 +15,9 @@ so:
|
||||||
```
|
```
|
||||||
|
|
||||||
The keys of this top-level JSON object correspond to the parameters that are
|
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
|
prompted by the `bootstrap init` curses interface. The value is used to
|
||||||
what kind of prompt `spec` provides for the given question. Possible value types
|
determine what kind of prompt `bootstrap` provides for the given question.
|
||||||
include:
|
Possible value types include:
|
||||||
|
|
||||||
* `[...]` (list)
|
* `[...]` (list)
|
||||||
* This indicates a select option prompt. The user chooses amongst the values
|
* This indicates a select option prompt. The user chooses amongst the values
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
ncurses
|
ncurses
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export SPEC_ROOT_DIR="${./specs}"
|
export BOOTSTRAP_ROOT_DIR="${./specs}"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#ifndef _SPEC_CONFIG_H
|
#ifndef _BOOTSTRAP_CONFIG_H
|
||||||
#define _SPEC_CONFIG_H
|
#define _BOOTSTRAP_CONFIG_H
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
// The directory the `spec` command was run from.
|
// The directory the `bootstrap` command was run from.
|
||||||
// OWNERSHIP: Does not own this pointer.
|
// OWNERSHIP: Does not own this pointer.
|
||||||
const char *cwd;
|
const char *cwd;
|
||||||
// The root directory housing our specs.
|
// The root directory housing our specs.
|
||||||
// OWNERSHIP: Does not own this pointer.
|
// OWNERSHIP: Does not own this pointer.
|
||||||
const char *root_dir;
|
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.
|
// OWNERSHIP: Does not own this pointer.
|
||||||
const char *target;
|
const char *target;
|
||||||
};
|
};
|
||||||
|
@ -16,8 +16,8 @@ struct Config {
|
||||||
enum ConfigError {
|
enum ConfigError {
|
||||||
// Indicates the $CWD could not be retrieved.
|
// Indicates the $CWD could not be retrieved.
|
||||||
CE_ENV_CWD_INVALID = 1,
|
CE_ENV_CWD_INVALID = 1,
|
||||||
// Indicates the `$SPEC_ROOT_DIR` environment variable is empty.
|
// Indicates the $BOOTSTRAP_ROOT_DIR environment variable is empty.
|
||||||
CE_ENV_SPEC_ROOT_DIR_INVALID,
|
CE_ENV_ROOT_DIR_INVALID,
|
||||||
// Indicates the target argument is invalid.
|
// Indicates the target argument is invalid.
|
||||||
CE_TARGET_INVALID,
|
CE_TARGET_INVALID,
|
||||||
};
|
};
|
||||||
|
@ -31,4 +31,4 @@ enum ConfigError config_load(
|
||||||
|
|
||||||
void config_free(struct Config *config);
|
void config_free(struct Config *config);
|
||||||
|
|
||||||
#endif /* _SPEC_CONFIG_H */
|
#endif /* BOOTSTRAP_CONFIG_H */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef _SPEC_DYN_ARRAY_H
|
#ifndef _BOOTSTRAP_DYN_ARRAY_H
|
||||||
#define _SPEC_DYN_ARRAY_H
|
#define _BOOTSTRAP_DYN_ARRAY_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -19,4 +19,4 @@ void dyn_array_push(struct DynArray *a, void *item);
|
||||||
|
|
||||||
void dyn_array_free(struct DynArray *a);
|
void dyn_array_free(struct DynArray *a);
|
||||||
|
|
||||||
#endif /* _SPEC_DYN_ARRAY_H */
|
#endif /* _BOOTSTRAP_DYN_ARRAY_H */
|
||||||
|
|
10
main.c
10
main.c
|
@ -5,18 +5,18 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "dyn_array.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 main(int argc, char **argv) {
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf(stderr, "Usage: gen-flake <spec>\n");
|
fprintf(stderr, "Usage: bootstrap <spec>\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *cwd = getcwd(0, 0);
|
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];
|
const char *target = argv[1];
|
||||||
|
|
||||||
struct Config *config = 0;
|
struct Config *config = 0;
|
||||||
|
@ -24,8 +24,8 @@ int main(int argc, char **argv) {
|
||||||
case CE_ENV_CWD_INVALID:
|
case CE_ENV_CWD_INVALID:
|
||||||
fprintf(stderr, "Could not retrieve the $CWD value.");
|
fprintf(stderr, "Could not retrieve the $CWD value.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
case CE_ENV_SPEC_ROOT_DIR_INVALID:
|
case CE_ENV_ROOT_DIR_INVALID:
|
||||||
fprintf(stderr, "Must specify $SPEC_ROOT_DIR environment variable.");
|
fprintf(stderr, "Must specify $BOOTSTRAP_ROOT_DIR environment variable.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
case CE_TARGET_INVALID:
|
case CE_TARGET_INVALID:
|
||||||
fprintf(stderr, "Target spec `%s` is invalid.", argv[1]);
|
fprintf(stderr, "Target spec `%s` is invalid.", argv[1]);
|
||||||
|
|
|
@ -13,7 +13,7 @@ enum ConfigError config_load(
|
||||||
return CE_ENV_CWD_INVALID;
|
return CE_ENV_CWD_INVALID;
|
||||||
}
|
}
|
||||||
if (root_dir == 0) {
|
if (root_dir == 0) {
|
||||||
return CE_ENV_SPEC_ROOT_DIR_INVALID;
|
return CE_ENV_ROOT_DIR_INVALID;
|
||||||
}
|
}
|
||||||
if (target == 0) {
|
if (target == 0) {
|
||||||
return CE_TARGET_INVALID;
|
return CE_TARGET_INVALID;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef _SPEC_TEST_CONFIG
|
#ifndef _BOOTSTRAP_TEST_CONFIG
|
||||||
#define _SPEC_TEST_CONFIG
|
#define _BOOTSTRAP_TEST_CONFIG
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "sput.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_ROOT_DIR = "/usr/local/share/specs";
|
||||||
static const char *SAMPLE_TARGET = "example-target";
|
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() {
|
static void test_config_load_root_dir_invalid() {
|
||||||
struct Config *config = 0;
|
struct Config *config = 0;
|
||||||
enum ConfigError retval = config_load(SAMPLE_CWD, 0, SAMPLE_TARGET, &config);
|
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() {
|
static void test_config_load_target_invalid() {
|
||||||
|
@ -42,4 +42,4 @@ static void test_config_load_success() {
|
||||||
config_free(config);
|
config_free(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _SPEC_TEST_CONFIG */
|
#endif /* _BOOTSTRAP_TEST_CONFIG */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef _SPEC_TEST_DYN_ARRAY
|
#ifndef _BOOTSTRAP_TEST_DYN_ARRAY
|
||||||
#define _SPEC_TEST_DYN_ARRAY
|
#define _BOOTSTRAP_TEST_DYN_ARRAY
|
||||||
|
|
||||||
#include "dyn_array.h"
|
#include "dyn_array.h"
|
||||||
#include "sput.h"
|
#include "sput.h"
|
||||||
|
@ -44,4 +44,4 @@ static void test_dyn_array_nonzero_capacity() {
|
||||||
dyn_array_free(a);
|
dyn_array_free(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _SPEC_TEST_DYN_ARRAY */
|
#endif /* _BOOTSTRAP_TEST_DYN_ARRAY */
|
||||||
|
|
Loading…
Reference in New Issue