Skip to content

Commit

Permalink
use DB_PATH env var
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanflorence committed Dec 9, 2024
1 parent f207051 commit 3e96161
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ if (args["--help"]) {
process.exit(0);
}

let dbPath = args._[0];
let dbPath = process.env.DB_PATH;
if (!dbPath) {
console.log(pc.red("Error:"), "Database path is required");
console.log(pc.red("Error:"), "DB_PATH env variable is not set");
printUsage();
process.exit(1);
}
Expand All @@ -41,16 +41,19 @@ if (args["--out"]) {
function printUsage() {
console.log(`
${pc.bold("USAGE")}
${pc.cyan("sqlite-typegen")} <db path> [options]
${pc.cyan("sqlite-typegen")} [options]
${pc.bold("ENVIRONMENT VARIABLES")}
${pc.yellow("DB_PATH")} Path to SQLite database file
${pc.bold("OPTIONS")}
-o, --out Output file path (optional)
-n, --namespace Namespace for generated types (optional)
-h, --help Print help message
${pc.bold("EXAMPLES")}
${pc.cyan("sqlite-typegen")} ./database.sqlite
${pc.cyan("sqlite-typegen")} ./database.sqlite --out types.ts
${pc.cyan("sqlite-typegen")} ./database.sqlite --out types.ts -n DB
${pc.cyan("sqlite-typegen")}
${pc.cyan("sqlite-typegen")} --out types.ts
${pc.cyan("sqlite-typegen")} --out types.ts -n DB
`);
}

0 comments on commit 3e96161

Please sign in to comment.