Skip to content

refactor: make URL a positional argument in fetch command#19

Merged
rolznz merged 3 commits intomasterfrom
refactor/fetch-url-positional-arg
Apr 9, 2026
Merged

refactor: make URL a positional argument in fetch command#19
rolznz merged 3 commits intomasterfrom
refactor/fetch-url-positional-arg

Conversation

@reneaaron
Copy link
Copy Markdown
Member

@reneaaron reneaaron commented Apr 8, 2026

Summary

  • Changed alby fetch -u <url> to alby fetch <url>, making the URL a positional argument instead of a required flag
  • AI agents naturally pass the URL as the main parameter, so this reduces errors when agents use the CLI

Test plan

  • Verify alby fetch https://example.com works
  • Verify alby fetch without a URL shows a usage error
  • Verify optional flags (-m, -b, -H, --max-amount) still work

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Updates
    • The fetch command now takes the URL as the first positional argument instead of a --url flag; other options (method, body, headers, max-amount) remain unchanged.
  • Documentation
    • README examples updated to show the new positional-URL usage (e.g., fetch "https://example.com/api") while preserving existing option examples.
  • Chores
    • Package/CLI version bumped to 0.5.0.

`alby fetch <url>` is more intuitive than `alby fetch -u <url>`,
especially for AI agents that naturally pass the URL as the main param.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1a569a3a-5d56-4d64-826f-160ca8d7675b

📥 Commits

Reviewing files that changed from the base of the PR and between 3d86a6a and 40ebf93.

📒 Files selected for processing (2)
  • package.json
  • src/index.ts

📝 Walkthrough

Walkthrough

The fetch command's URL input was changed from a required --url <url> option to a positional <url> argument. The command action signature was updated from (options) to (url, options), and fetch402 now receives the positional url. Documentation and CLI version were updated accordingly.

Changes

Cohort / File(s) Summary
Command implementation
src/commands/fetch.ts
Replaced required --url <url> option with a positional <url> argument; updated .action handler signature to (url, options) and call to fetch402(url, ...). Other flags (--method, --body, --headers, --max-amount) unchanged.
Documentation
README.md
Updated fetch examples to pass the URL as the first positional argument instead of --url <url>; example flags unchanged.
Version bump
package.json, src/index.ts
Package and CLI program version updated from 0.4.1 to 0.5.0 in both files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Poem

🐇 I hopped from flag to path with glee,
The URL now greets me first, you see,
No dashed flag to chase or curl,
It sits right there — a positional pearl,
Fetch hops on — a joyful swirl.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: converting the URL from a required flag to a positional argument in the fetch command.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/fetch-url-positional-arg

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/commands/fetch.ts (1)

11-11: Consider a deprecation bridge for --url to avoid breaking existing scripts.

Switching to positional URL is good, but this is a breaking CLI change. Consider accepting --url as deprecated for one release and preferring positional when both are supplied.

Proposed compatibility diff
     .argument("<url>", "URL to fetch")
+    .option("-u, --url <url>", "DEPRECATED: use positional <url> instead")
@@
-    .action(async (url, options) => {
+    .action(async (url, options) => {
       await handleError(async () => {
+        const resolvedUrl = url ?? options.url;
+        if (!resolvedUrl) {
+          throw new Error("URL is required");
+        }
         const client = await getClient(program);
         const result = await fetch402(client, {
-          url: url,
+          url: resolvedUrl,
           method: options.method,
           body: options.body,
           headers: options.headers ? JSON.parse(options.headers) : undefined,
           maxAmountSats: options.maxAmount,
         });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/fetch.ts` at line 11, Add a deprecated CLI flag bridge so
existing scripts using --url keep working: keep the positional argument
declaration (.argument("<url>", "URL to fetch")) and also add an option('--url
<url>', 'Deprecated: use positional URL') to the command; in the command handler
prefer the positional URL when both are supplied, otherwise fall back to the
option value, and emit a single deprecation warning when --url is used (e.g.,
via console.warn or the logger) that tells users to switch to the positional
form and that --url will be removed in the next release.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/commands/fetch.ts`:
- Line 11: Add a deprecated CLI flag bridge so existing scripts using --url keep
working: keep the positional argument declaration (.argument("<url>", "URL to
fetch")) and also add an option('--url <url>', 'Deprecated: use positional URL')
to the command; in the command handler prefer the positional URL when both are
supplied, otherwise fall back to the option value, and emit a single deprecation
warning when --url is used (e.g., via console.warn or the logger) that tells
users to switch to the positional form and that --url will be removed in the
next release.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 45140e36-8f99-440d-a510-02ec9314c457

📥 Commits

Reviewing files that changed from the base of the PR and between 262ad3a and 8a60f2b.

📒 Files selected for processing (1)
  • src/commands/fetch.ts

@reneaaron reneaaron requested a review from rolznz April 8, 2026 12:27
Copy link
Copy Markdown
Member

@rolznz rolznz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@rolznz rolznz merged commit 44ab9fa into master Apr 9, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants