Skip to content

feat: initial Notehub CLI V2#62

Open
Bucknalla wants to merge 18 commits intomasterfrom
alex-notehub-cli-v2
Open

feat: initial Notehub CLI V2#62
Bucknalla wants to merge 18 commits intomasterfrom
alex-notehub-cli-v2

Conversation

@Bucknalla
Copy link
Collaborator

No description provided.

@Bucknalla Bucknalla marked this pull request as draft December 5, 2025 11:29
}

projectsRsp := ProjectsResponse{}
err := reqHubV1(GetVerbose(), GetAPIHub(), "GET", "/v1/projects", nil, &projectsRsp)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should consider using the Notehub Golang SDK instead of essentially rewriting it by hand. It'll be a LOT less code and have better compile-time checks

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@scottfrazer I was planning on this but I believe it's private to the hub repo? I'm happy to change over to using it otherwise

Copy link
Contributor

Choose a reason for hiding this comment

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

For example, instead of duplicating the Project and ProjectResponse objects and having to do the HTTP request, we could do:

projects, httpResp, err := sdk.ProjectAPI.
		GetProjects(ctx).
		Execute()

This SDK is automatically generated from the OpenAPI spec

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it is private currently. We need to develop a process to publish it (like we for the JavaScript SDK). So far we haven't done it simply because there wasn't a specific need for it since we only use the SDK internally right now

But there's no reason why it shouldn't be public!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me know when you have a mechanism to publish it, and I'll change over to use it! Looking forward to it!

Bucknalla and others added 6 commits December 8, 2025 17:07
…ling, and V1 migration

- Add new commands: billing, event, monitor, note, notefile, usage, docs
- Add set/clear subcommands for fleet, route, monitor, and product defaults
- Add hybrid pagination (--limit/--all) to list commands
- Migrate explore command from V0 to SDK (ListNotefiles/GetNotefile)
- Improve network error handling with user-friendly messages
- Remove unused V0 wrapper functions and clean up imports
- Add auto-generated CLI docs via cobra/doc
- Add notehub/doc/ to .gitignore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Bucknalla Bucknalla marked this pull request as ready for review March 13, 2026 19:20
Bucknalla and others added 9 commits March 13, 2026 19:23
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cobra defaults cmd.Printf to stderr when no output writer is set.
This prevented piping --json/--pretty output to tools like jq.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes strict JSON deserialization that rejected unknown fields from the API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rdize patterns

- Add printActionResult helper for --json support on 18 action/mutation commands
- Add validateAuth to replace GetCredentials (which called os.Exit, bypassing Cobra)
- Add resolveProduct, resolveMonitor helpers for UID-or-name lookup
- Add pickPaginated helper with colorless theme, used by all resource pickers
- Add device picker to all single-device commands (get, delete, signal, health, etc.)
- Add cursor-based --all pagination to event list
- Extract deviceEnableDisable shared helper for enable/disable commands
- Extract dfuAction shared helper for DFU update/cancel commands
- Share scopeHelpLong constant and addScopeFlag helper across scope-using commands
- Standardize error messages (consistent format for not-found, missing input, auth)
- Standardize success messages (no "successfully!", no trailing punctuation)
- Fix isNetworkError false positive on *os.PathError (satisfies net.Error interface)
- Remove dead GetCredentials function from root.go

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ructive actions

- Add device set/clear to persist a default device (used by get, health,
  session, events, plans, keys, signal, delete when no arg given)
- Add confirmAction helper with --yes/-y flag to skip prompt
- Add confirmation to all destructive commands: device delete, device disable,
  project delete, product delete, fleet delete, route delete, monitor delete,
  note delete, notefile delete
- Fix route create/update to use printMutationResult for --json support
- Fix setDefault display when label equals UID (no redundant parenthetical)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…V1 migration hints

- Add bulk provisioning from CSV/JSON files (--file flag) with per-device
  serial numbers and fleet UIDs
- Add vars delete command to remove env vars from devices, fleets, or project
- Add device config command showing full env var hierarchy with inheritance
- Add retry logic with exponential backoff (3 retries, 500ms/1s/2s) on all
  HTTP calls (SDK, V0 API, upload) for transient 5xx and network errors
- Add V1 CLI migration hints: old flags like -signin, -explore, -req show
  the equivalent V2 command syntax

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Settings now display structured UID/label fields instead of just the raw
UID, making it easier to identify the active project at a glance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix retryTransport to reset request body via GetBody before retries,
  and skip retry for non-replayable POST/PUT bodies
- Deduplicate auth logic: initCommand now calls validateAuth internally
- Extract pickerNext/pickerPrev constants for navigation sentinel values
- Use scopeHelpLong in deviceMoveCmd (was the only scope command missing it)
- Use pastTense variable instead of string concatenation in verbose output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move version variable to main.go so GoReleaser's default ldflags
(-X main.version) work automatically. Simplify --version output to
just print the version string without the "notehub version" prefix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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