-
Notifications
You must be signed in to change notification settings - Fork 0
Add CLI flags for bun-worker configuration #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
sdks/bun-worker/package-lock.json
Outdated
| @@ -0,0 +1,741 @@ | |||
| { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot we use bun in this package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed package-lock.json and added it to .gitignore. The package now properly uses bun.lock for dependency management. (bcf13ef)
bcho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
|
Hi! How can I help? Could you please provide more details about what you'd like me to address? |
bcho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
samples/bun-worker/README.md
Outdated
| @@ -0,0 +1,59 @@ | |||
| # Bun Worker Sample | |||
|
|
|||
| This sample demonstrates how to use the `@absurd-sqlite/bun-worker` SDK to create a worker that processes tasks. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this readme file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed samples/bun-worker/README.md (d77d116)
samples/bun-worker/src/index.ts
Outdated
| configureBunSqlite(); | ||
|
|
||
| // The worker now supports CLI flags for configuration: | ||
| // --concurrency (-c): Number of concurrent tasks (default: 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expose only --concurrency flag for now. Add two more flags for specifying the extension path and database path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to expose only --concurrency, --database, and --extension flags (d77d116)
sdks/bun-worker/README.md
Outdated
| }); | ||
| ``` | ||
|
|
||
| ## CLI Flags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the CLI Flags section from README (d77d116)
- Remove samples/bun-worker/README.md - Use cac for CLI parsing with help messages - Expose only --concurrency, --database, and --extension flags - Remove extensive CLI documentation from SDK README - Update error messages and tests Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
bcho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sdks/bun-worker/README.md
Outdated
| }); | ||
| ``` | ||
|
|
||
| ## Programmatic Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the Programmatic Configuration section from README (697101b)
sdks/bun-worker/src/index.ts
Outdated
| * Whether to parse CLI flags for worker configuration. | ||
| * Defaults to true. | ||
| */ | ||
| parseCliFlags?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed parseCliFlags option from RunOptions (697101b)
sdks/bun-worker/src/index.ts
Outdated
| ): Promise<void> { | ||
| const parseFlags = options?.parseCliFlags !== false; | ||
|
|
||
| let dbPath = process.env.ABSURD_DATABASE_PATH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract the options parsing to a helper function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted CLI parsing to parseCliOptions() helper function (697101b)
sdks/bun-worker/src/index.ts
Outdated
| .option("-c, --concurrency <number>", "Number of tasks to process concurrently", { | ||
| default: 10, | ||
| }) | ||
| .option("-d, --database <path>", "SQLite database file path") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use --database-path and --extension-path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to --database-path and --extension-path (697101b)
- Remove parseCliFlags option from RunOptions - Extract CLI parsing to parseCliOptions helper function - Rename flags to --database-path and --extension-path - Remove Programmatic Configuration section from README - Update tests to remove parseCliFlags test case Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
sdks/bun-worker/src/index.ts
Outdated
| /** | ||
| * Configuration options for the worker runtime. | ||
| */ | ||
| export interface RunOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this options instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed RunOptions interface and the options parameter from run() function. Configuration is now only through CLI flags and environment variables. (715b562)
- Remove RunOptions interface and options parameter from run() - Worker configuration now only through CLI flags and defaults - Remove test for programmatic workerOptions configuration - Simplifies API surface to focus on CLI-based configuration Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
bcho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bun run src/index.ts -- --help
bun-worker
Usage:
$ bun-worker <command> [options]
Options:
-c, --concurrency <number> Number of tasks to process concurrently (default: 10)
--database-path <path> SQLite database file path
--extension-path <path> Absurd-SQLite extension path
-h, --help Display this message
6084 | }
6085 | async function run(setupFunction) {
6086 | const cliOptions = parseCliOptions();
6087 | const dbPath = cliOptions.dbPath || process.env.ABSURD_DATABASE_PATH;
6088 | const extensionPath = cliOptions.extensionPath || process.env.ABSURD_DATABASE_EXTENSION_PATH;
6089 | throw new Error("Database path is required. Set ABSURD_DATABASE_PATH environment variable or use --database-path flag.");
^
when -h is being used, no stacktrace should be dump
|
@copilot no i mean when using |
When --help is used, cac displays help and sets the help option. Previously, the program would continue execution and fail with "Database path is required" error. Now it exits gracefully with exit code 0 after showing help. Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
Add CLI flags to configure bun-worker settings
run()function to only accept setup functionSummary
This PR adds CLI flag support to the bun-worker SDK using the
caclibrary, providing a simple command-line interface for worker configuration.Available CLI Flags
--concurrency,-c: Number of tasks to process concurrently (default: 10)--database-path: SQLite database file path (overrides ABSURD_DATABASE_PATH environment variable)--extension-path: Absurd-SQLite extension path (overrides ABSURD_DATABASE_EXTENSION_PATH environment variable)--help,-h: Display help informationImplementation Details
caclibrary for CLI parsing with proper help messagesparseCliOptions()helper function for clean code organizationrun(setupFunction)--helpflag exits gracefully without requiring database configurationUsage
The implementation provides a focused CLI interface for essential options. All configuration is done via CLI flags or environment variables.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.