feat: rename --store to --home for OCAS_HOME consistency #11
@@ -32,7 +32,7 @@ type Flags = Record<string, string | boolean | string[]>;
|
|||||||
|
|
||||||
/** Flags that consume the next token as their value. All others are boolean. */
|
/** Flags that consume the next token as their value. All others are boolean. */
|
||||||
const VALUE_FLAGS = new Set([
|
const VALUE_FLAGS = new Set([
|
||||||
"store",
|
"home",
|
||||||
"format",
|
"format",
|
||||||
"var-db",
|
"var-db",
|
||||||
"tag",
|
"tag",
|
||||||
@@ -89,8 +89,8 @@ const { flags, positional } = parseArgs(process.argv.slice(2));
|
|||||||
|
|
||||||
const defaultStorePath = join(homedir(), ".ocas");
|
const defaultStorePath = join(homedir(), ".ocas");
|
||||||
const storePath =
|
const storePath =
|
||||||
typeof flags.store === "string"
|
typeof flags.home === "string"
|
||||||
? flags.store
|
? flags.home
|
||||||
: (process.env["OCAS_HOME"] ?? defaultStorePath);
|
: (process.env["OCAS_HOME"] ?? defaultStorePath);
|
||||||
const compact = flags.json === true;
|
const compact = flags.json === true;
|
||||||
|
|
||||||
@@ -849,7 +849,7 @@ async function cmdListSchema(_args: string[]): Promise<void> {
|
|||||||
|
|
||||||
function printUsage(): void {
|
function printUsage(): void {
|
||||||
console.log(`\
|
console.log(`\
|
||||||
Usage: ocas [--store <path>] [--json] <command> [args]
|
Usage: ocas [--home <path>] [--json] <command> [args]
|
||||||
|
|
||||||
All JSON commands emit a { type, value } envelope. The type is the hash of the
|
All JSON commands emit a { type, value } envelope. The type is the hash of the
|
||||||
command's @ocas/output/* schema (shown in parentheses); pipe any envelope into
|
command's @ocas/output/* schema (shown in parentheses); pipe any envelope into
|
||||||
@@ -880,7 +880,7 @@ Commands:
|
|||||||
gc Run garbage collection (@ocas/output/gc)
|
gc Run garbage collection (@ocas/output/gc)
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
--store <path> Store directory (default: $OCAS_HOME or ~/.ocas)
|
--home <path> Store directory (default: $OCAS_HOME or ~/.ocas)
|
||||||
--var-db <path> Variable database path (default: <store>/variables.db)
|
--var-db <path> Variable database path (default: <store>/variables.db)
|
||||||
--json Compact JSON output
|
--json Compact JSON output
|
||||||
--schema <hash> Schema hash filter for var get/delete/tag/list
|
--schema <hash> Schema hash filter for var get/delete/tag/list
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ exports[`Phase 7: Edge Cases 7.3 var set empty name errors 1`] = `"Usage: ocas v
|
|||||||
exports[`Phase 7: Edge Cases 7.4 var set name with invalid chars errors 1`] = `"Error: Invalid variable name "invalid name!": Segment "invalid name!" contains invalid characters (only @, a-z, A-Z, 0-9, ., _, - allowed)"`;
|
exports[`Phase 7: Edge Cases 7.4 var set name with invalid chars errors 1`] = `"Error: Invalid variable name "invalid name!": Segment "invalid name!" contains invalid characters (only @, a-z, A-Z, 0-9, ., _, - allowed)"`;
|
||||||
|
|
||||||
exports[`Phase 7: Edge Cases 7.5 no subcommand shows help text 1`] = `
|
exports[`Phase 7: Edge Cases 7.5 no subcommand shows help text 1`] = `
|
||||||
"Usage: ocas [--store <path>] [--json] <command> [args]
|
"Usage: ocas [--home <path>] [--json] <command> [args]
|
||||||
|
|
||||||
All JSON commands emit a { type, value } envelope. The type is the hash of the
|
All JSON commands emit a { type, value } envelope. The type is the hash of the
|
||||||
command's @ocas/output/* schema (shown in parentheses); pipe any envelope into
|
command's @ocas/output/* schema (shown in parentheses); pipe any envelope into
|
||||||
@@ -38,7 +38,7 @@ Commands:
|
|||||||
gc Run garbage collection (@ocas/output/gc)
|
gc Run garbage collection (@ocas/output/gc)
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
--store <path> Store directory (default: ~/.ocas)
|
--home <path> Store directory (default: $OCAS_HOME or ~/.ocas)
|
||||||
--var-db <path> Variable database path (default: <store>/variables.db)
|
--var-db <path> Variable database path (default: <store>/variables.db)
|
||||||
--json Compact JSON output
|
--json Compact JSON output
|
||||||
--schema <hash> Schema hash filter for var get/delete/tag/list
|
--schema <hash> Schema hash filter for var get/delete/tag/list
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ async function runCliAlias(...args: string[]): Promise<{
|
|||||||
exitCode: number;
|
exitCode: number;
|
||||||
}> {
|
}> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", "run", cliPath, "--store", storePath, ...args],
|
["bun", "run", cliPath, "--home", storePath, ...args],
|
||||||
{
|
{
|
||||||
stdout: "pipe",
|
stdout: "pipe",
|
||||||
stderr: "pipe",
|
stderr: "pipe",
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ describe("Phase 7: Edge Cases", () => {
|
|||||||
args: string[],
|
args: string[],
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", entrypoint, "--store", tmpStore, "--var-db", varDbPath, ...args],
|
["bun", entrypoint, "--home", tmpStore, "--var-db", varDbPath, ...args],
|
||||||
{ stdout: "pipe", stderr: "pipe" },
|
{ stdout: "pipe", stderr: "pipe" },
|
||||||
);
|
);
|
||||||
const exitCode = await proc.exited;
|
const exitCode = await proc.exited;
|
||||||
@@ -130,14 +130,14 @@ describe("Phase 7: Edge Cases", () => {
|
|||||||
expect(combined.toLowerCase()).toContain("usage");
|
expect(combined.toLowerCase()).toContain("usage");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("7.6 --store path is a file errors", async () => {
|
test("7.6 --home path is a file errors", async () => {
|
||||||
const fileAsStore = join(tmpStore, "not-a-directory");
|
const fileAsStore = join(tmpStore, "not-a-directory");
|
||||||
writeFileSync(fileAsStore, "test");
|
writeFileSync(fileAsStore, "test");
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
[
|
[
|
||||||
"bun",
|
"bun",
|
||||||
entrypoint,
|
entrypoint,
|
||||||
"--store",
|
"--home",
|
||||||
fileAsStore,
|
fileAsStore,
|
||||||
"--var-db",
|
"--var-db",
|
||||||
varDbPath,
|
varDbPath,
|
||||||
@@ -165,7 +165,7 @@ describe("Phase 3: Variable System", () => {
|
|||||||
args: string[],
|
args: string[],
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", entrypoint, "--store", tmpStore, "--var-db", varDbPath, ...args],
|
["bun", entrypoint, "--home", tmpStore, "--var-db", varDbPath, ...args],
|
||||||
{ stdout: "pipe", stderr: "pipe" },
|
{ stdout: "pipe", stderr: "pipe" },
|
||||||
);
|
);
|
||||||
const exitCode = await proc.exited;
|
const exitCode = await proc.exited;
|
||||||
@@ -354,7 +354,7 @@ describe("Phase 4: Template System", () => {
|
|||||||
args: string[],
|
args: string[],
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", entrypoint, "--store", tmpStore, "--var-db", varDbPath, ...args],
|
["bun", entrypoint, "--home", tmpStore, "--var-db", varDbPath, ...args],
|
||||||
{ stdout: "pipe", stderr: "pipe" },
|
{ stdout: "pipe", stderr: "pipe" },
|
||||||
);
|
);
|
||||||
const exitCode = await proc.exited;
|
const exitCode = await proc.exited;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ async function runCli(
|
|||||||
args: string[],
|
args: string[],
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", entrypoint, "--store", tmpStore, "--var-db", varDbPath, ...args],
|
["bun", entrypoint, "--home", tmpStore, "--var-db", varDbPath, ...args],
|
||||||
{ stdout: "pipe", stderr: "pipe" },
|
{ stdout: "pipe", stderr: "pipe" },
|
||||||
);
|
);
|
||||||
const exitCode = await proc.exited;
|
const exitCode = await proc.exited;
|
||||||
@@ -84,7 +84,7 @@ describe("Phase 6: GC", () => {
|
|||||||
[
|
[
|
||||||
"bun",
|
"bun",
|
||||||
entrypoint,
|
entrypoint,
|
||||||
"--store",
|
"--home",
|
||||||
tmpStore,
|
tmpStore,
|
||||||
"--var-db",
|
"--var-db",
|
||||||
varDbPath,
|
varDbPath,
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export async function runCli(
|
|||||||
storePath?: string,
|
storePath?: string,
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const finalArgs = storePath
|
const finalArgs = storePath
|
||||||
? ["bun", entrypoint, "--store", storePath, ...args]
|
? ["bun", entrypoint, "--home", storePath, ...args]
|
||||||
: ["bun", entrypoint, ...args];
|
: ["bun", entrypoint, ...args];
|
||||||
const proc = Bun.spawn(finalArgs, {
|
const proc = Bun.spawn(finalArgs, {
|
||||||
stdout: "pipe",
|
stdout: "pipe",
|
||||||
@@ -72,7 +72,7 @@ export async function runCliWithStdin(
|
|||||||
storePath: string,
|
storePath: string,
|
||||||
stdin: string,
|
stdin: string,
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const finalArgs = ["bun", entrypoint, "--store", storePath, ...args];
|
const finalArgs = ["bun", entrypoint, "--home", storePath, ...args];
|
||||||
const proc = Bun.spawn(finalArgs, {
|
const proc = Bun.spawn(finalArgs, {
|
||||||
stdout: "pipe",
|
stdout: "pipe",
|
||||||
stderr: "pipe",
|
stderr: "pipe",
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ async function runCli(
|
|||||||
args: string[],
|
args: string[],
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", entrypoint, "--store", tmpStore, "--var-db", varDbPath, ...args],
|
["bun", entrypoint, "--home", tmpStore, "--var-db", varDbPath, ...args],
|
||||||
{ stdout: "pipe", stderr: "pipe" },
|
{ stdout: "pipe", stderr: "pipe" },
|
||||||
);
|
);
|
||||||
const exitCode = await proc.exited;
|
const exitCode = await proc.exited;
|
||||||
@@ -66,7 +66,7 @@ async function runCliWithStdin(
|
|||||||
stdin: string,
|
stdin: string,
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", entrypoint, "--store", tmpStore, "--var-db", varDbPath, ...args],
|
["bun", entrypoint, "--home", tmpStore, "--var-db", varDbPath, ...args],
|
||||||
{ stdin: "pipe", stdout: "pipe", stderr: "pipe" },
|
{ stdin: "pipe", stdout: "pipe", stderr: "pipe" },
|
||||||
);
|
);
|
||||||
proc.stdin.write(stdin);
|
proc.stdin.write(stdin);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ async function runCli(
|
|||||||
args: string[],
|
args: string[],
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", entrypoint, "--store", tmpStore, "--var-db", varDbPath, ...args],
|
["bun", entrypoint, "--home", tmpStore, "--var-db", varDbPath, ...args],
|
||||||
{ stdout: "pipe", stderr: "pipe" },
|
{ stdout: "pipe", stderr: "pipe" },
|
||||||
);
|
);
|
||||||
const exitCode = await proc.exited;
|
const exitCode = await proc.exited;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ describe("Phase 5: Render", () => {
|
|||||||
args: string[],
|
args: string[],
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", entrypoint, "--store", tmpStore, "--var-db", varDbPath, ...args],
|
["bun", entrypoint, "--home", tmpStore, "--var-db", varDbPath, ...args],
|
||||||
{ stdout: "pipe", stderr: "pipe" },
|
{ stdout: "pipe", stderr: "pipe" },
|
||||||
);
|
);
|
||||||
const exitCode = await proc.exited;
|
const exitCode = await proc.exited;
|
||||||
@@ -76,7 +76,7 @@ describe("Phase 5: Render", () => {
|
|||||||
stdin: string,
|
stdin: string,
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", entrypoint, "--store", tmpStore, "--var-db", varDbPath, ...args],
|
["bun", entrypoint, "--home", tmpStore, "--var-db", varDbPath, ...args],
|
||||||
{ stdin: "pipe", stdout: "pipe", stderr: "pipe" },
|
{ stdin: "pipe", stdout: "pipe", stderr: "pipe" },
|
||||||
);
|
);
|
||||||
proc.stdin.write(stdin);
|
proc.stdin.write(stdin);
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ describe("Phase 2: Schema Validation", () => {
|
|||||||
[
|
[
|
||||||
"bun",
|
"bun",
|
||||||
entrypoint,
|
entrypoint,
|
||||||
"--store",
|
"--home",
|
||||||
tmpStore,
|
tmpStore,
|
||||||
"--var-db",
|
"--var-db",
|
||||||
varDbPath,
|
varDbPath,
|
||||||
@@ -616,7 +616,7 @@ describe("Phase 2: Schema Validation", () => {
|
|||||||
[
|
[
|
||||||
"bun",
|
"bun",
|
||||||
entrypoint,
|
entrypoint,
|
||||||
"--store",
|
"--home",
|
||||||
tmpStore,
|
tmpStore,
|
||||||
"--var-db",
|
"--var-db",
|
||||||
varDbPath,
|
varDbPath,
|
||||||
@@ -641,7 +641,7 @@ describe("Phase 2: Schema Validation", () => {
|
|||||||
[
|
[
|
||||||
"bun",
|
"bun",
|
||||||
entrypoint,
|
entrypoint,
|
||||||
"--store",
|
"--home",
|
||||||
tmpStore,
|
tmpStore,
|
||||||
"--var-db",
|
"--var-db",
|
||||||
varDbPath,
|
varDbPath,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ async function runCli(...args: string[]): Promise<{
|
|||||||
"bun",
|
"bun",
|
||||||
"run",
|
"run",
|
||||||
cliPath,
|
cliPath,
|
||||||
"--store",
|
"--home",
|
||||||
storePath,
|
storePath,
|
||||||
"--var-db",
|
"--var-db",
|
||||||
varDbPath,
|
varDbPath,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ async function runCli(...args: string[]): Promise<{
|
|||||||
"bun",
|
"bun",
|
||||||
"run",
|
"run",
|
||||||
cliPath,
|
cliPath,
|
||||||
"--store",
|
"--home",
|
||||||
storePath,
|
storePath,
|
||||||
"--var-db",
|
"--var-db",
|
||||||
varDbPath,
|
varDbPath,
|
||||||
@@ -949,7 +949,7 @@ describe("global options", () => {
|
|||||||
expect(lines.length).toBe(1);
|
expect(lines.length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("--store flag for custom store path", async () => {
|
test("--home flag for custom store path", async () => {
|
||||||
const customStorePath = join(testDir, "custom-store");
|
const customStorePath = join(testDir, "custom-store");
|
||||||
mkdirSync(customStorePath, { recursive: true });
|
mkdirSync(customStorePath, { recursive: true });
|
||||||
|
|
||||||
@@ -963,7 +963,7 @@ describe("global options", () => {
|
|||||||
"bun",
|
"bun",
|
||||||
"run",
|
"run",
|
||||||
cliPath,
|
cliPath,
|
||||||
"--store",
|
"--home",
|
||||||
customStorePath,
|
customStorePath,
|
||||||
"--var-db",
|
"--var-db",
|
||||||
varDbPath,
|
varDbPath,
|
||||||
@@ -994,7 +994,7 @@ describe("global options", () => {
|
|||||||
"bun",
|
"bun",
|
||||||
"run",
|
"run",
|
||||||
cliPath,
|
cliPath,
|
||||||
"--store",
|
"--home",
|
||||||
storePath,
|
storePath,
|
||||||
"--var-db",
|
"--var-db",
|
||||||
customDbPath,
|
customDbPath,
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ async function runCli(
|
|||||||
args: string[],
|
args: string[],
|
||||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||||
const proc = Bun.spawn(
|
const proc = Bun.spawn(
|
||||||
["bun", entrypoint, "--store", tmpStore, "--var-db", varDbPath, ...args],
|
["bun", entrypoint, "--home", tmpStore, "--var-db", varDbPath, ...args],
|
||||||
{ stdout: "pipe", stderr: "pipe" },
|
{ stdout: "pipe", stderr: "pipe" },
|
||||||
);
|
);
|
||||||
const exitCode = await proc.exited;
|
const exitCode = await proc.exited;
|
||||||
|
|||||||
Reference in New Issue
Block a user