rename web/ to admin/, along with the web-named build and cli identifiers
This commit is contained in:
+17
-17
@@ -69,12 +69,12 @@ pub const ImportArgs = struct { paths: Paths = .{}, file: []const u8, allow_dele
|
||||
/// makes that file the sole declarative source of truth: it is read, validated
|
||||
/// and reconciled into the database on every start.
|
||||
///
|
||||
/// `web_dev` is milestone-8 ruling 24's `--web-dev <dir>`: serve the web
|
||||
/// `admin_dev` is milestone-8 ruling 24's `--admin-dev <dir>`: serve the web
|
||||
/// interface from that directory instead of the embedded assets.
|
||||
pub const RunArgs = struct {
|
||||
paths: Paths = .{},
|
||||
config: ?[]const u8 = null,
|
||||
web_dev: ?[]const u8 = null,
|
||||
admin_dev: ?[]const u8 = null,
|
||||
};
|
||||
|
||||
pub const Command = union(enum) {
|
||||
@@ -179,7 +179,7 @@ fn flagValue(flag: Flag, argv: []const []const u8, i: *usize) ParseError![]const
|
||||
return argv[i.*];
|
||||
}
|
||||
|
||||
/// `run` takes `check`'s two flags plus `--web-dev`, which only a process that
|
||||
/// `run` takes `check`'s two flags plus `--admin-dev`, which only a process that
|
||||
/// serves has any use for; `check` deliberately rejects it.
|
||||
fn parseRunArgs(argv: []const []const u8) ParseError!RunArgs {
|
||||
var args: RunArgs = .{};
|
||||
@@ -190,8 +190,8 @@ fn parseRunArgs(argv: []const []const u8) ParseError!RunArgs {
|
||||
args.paths.data_dir = try flagValue(flag, argv, &i);
|
||||
} else if (eql(flag.name, "config")) {
|
||||
args.config = try flagValue(flag, argv, &i);
|
||||
} else if (eql(flag.name, "web-dev")) {
|
||||
args.web_dev = try flagValue(flag, argv, &i);
|
||||
} else if (eql(flag.name, "admin-dev")) {
|
||||
args.admin_dev = try flagValue(flag, argv, &i);
|
||||
} else return error.UnknownFlag;
|
||||
}
|
||||
return args;
|
||||
@@ -396,7 +396,7 @@ const usage_text =
|
||||
\\ check: grade FILE instead of the database
|
||||
\\ --out FILE write the export to FILE instead of stdout
|
||||
\\ --allow-delete let import apply a file whose diff deletes rows
|
||||
\\ --web-dev DIR run only: serve the web interface from DIR instead of
|
||||
\\ --admin-dev DIR run only: serve the web interface from DIR instead of
|
||||
\\ the embedded assets
|
||||
\\
|
||||
;
|
||||
@@ -1030,7 +1030,7 @@ test "run without --config selects database authority" {
|
||||
const command = try parseArgs(&.{"run"});
|
||||
try testing.expectEqualStrings("/var/lib/nxdns", command.run.paths.data_dir);
|
||||
try testing.expectEqual(@as(?[]const u8, null), command.run.config);
|
||||
try testing.expectEqual(@as(?[]const u8, null), command.run.web_dev);
|
||||
try testing.expectEqual(@as(?[]const u8, null), command.run.admin_dev);
|
||||
}
|
||||
|
||||
test "run --config selects file authority and the path lands in the run args" {
|
||||
@@ -1042,19 +1042,19 @@ test "run --config selects file authority and the path lands in the run args" {
|
||||
try testing.expectEqualStrings("/tmp/c.zon", command.run.config.?);
|
||||
}
|
||||
|
||||
test "parseArgs accepts run with --web-dev in both spellings" {
|
||||
const attached = try parseArgs(&.{ "run", "--web-dev=web/dist" });
|
||||
try testing.expectEqualStrings("web/dist", attached.run.web_dev.?);
|
||||
test "parseArgs accepts run with --admin-dev in both spellings" {
|
||||
const attached = try parseArgs(&.{ "run", "--admin-dev=admin/dist" });
|
||||
try testing.expectEqualStrings("admin/dist", attached.run.admin_dev.?);
|
||||
|
||||
const separate = try parseArgs(&.{ "run", "--web-dev", "web/dist" });
|
||||
try testing.expectEqualStrings("web/dist", separate.run.web_dev.?);
|
||||
const separate = try parseArgs(&.{ "run", "--admin-dev", "admin/dist" });
|
||||
try testing.expectEqualStrings("admin/dist", separate.run.admin_dev.?);
|
||||
}
|
||||
|
||||
test "parseArgs rejects --web-dev without a value and outside run" {
|
||||
try testing.expectError(error.MissingValue, parseArgs(&.{ "run", "--web-dev" }));
|
||||
try testing.expectError(error.MissingValue, parseArgs(&.{ "run", "--web-dev=" }));
|
||||
try testing.expectError(error.UnknownFlag, parseArgs(&.{ "check", "--web-dev", "web/dist" }));
|
||||
try testing.expectError(error.UnknownFlag, parseArgs(&.{ "export", "--web-dev", "web/dist" }));
|
||||
test "parseArgs rejects --admin-dev without a value and outside run" {
|
||||
try testing.expectError(error.MissingValue, parseArgs(&.{ "run", "--admin-dev" }));
|
||||
try testing.expectError(error.MissingValue, parseArgs(&.{ "run", "--admin-dev=" }));
|
||||
try testing.expectError(error.UnknownFlag, parseArgs(&.{ "check", "--admin-dev", "admin/dist" }));
|
||||
try testing.expectError(error.UnknownFlag, parseArgs(&.{ "export", "--admin-dev", "admin/dist" }));
|
||||
}
|
||||
|
||||
test "parseArgs accepts --data-dir with and without an equals sign" {
|
||||
|
||||
Reference in New Issue
Block a user