Skip to content

refactor: simplify CLI args by consolidating options#106

Closed
cgrinds wants to merge 1 commit into
mainfrom
cbg-cli
Closed

refactor: simplify CLI args by consolidating options#106
cgrinds wants to merge 1 commit into
mainfrom
cbg-cli

Conversation

@cgrinds
Copy link
Copy Markdown
Collaborator

@cgrinds cgrinds commented Apr 10, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 10, 2026 17:11
@cla-bot cla-bot Bot added the cla-signed label Apr 10, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the CLI/server startup options by consolidating the previously duplicated CLI flag definitions into a shared server.Config type and updating server initialization accordingly.

Changes:

  • Replaces server.Options with server.Config (including CLI flag metadata) and updates server.NewApp to accept it.
  • Embeds server.Config into the start command to avoid re-declaring CLI flags in cmd.
  • Moves the (formerly options-based) test HTTP client hook onto App (but does not currently wire it up).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
server/server.go Introduces server.Config, updates App/NewApp signature, and adjusts client creation logic.
cmd/cmds.go Embeds server.Config into StartCmd and passes it directly into server.NewApp.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/server.go
Comment on lines +33 to +37
type Config struct {
Host string `default:"localhost" help:"Listening address"`
Port int `default:"8080" help:"Listening port" env:"ONTAP_MCP_PORT"`
InspectTraffic bool `default:"false" help:"Inspect MCP HTTP traffic"`
ReadOnly bool `default:"false" help:"Run MCP in read-only mode. This disables all tool calls that modify ONTAP state."`
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

server.Config now carries CLI-specific kong tags (default, help, env). This couples the server package API to the CLI parser and makes it easy to assume defaults are applied when constructing server.Config programmatically (they are only applied by kong). Consider keeping server.Config as a parser-agnostic runtime config and defining a separate CLI flags struct in cmd (or using a type alias/wrapper) to hold kong tags.

Copilot uses AI. Check for mistakes.
Comment thread server/server.go
Comment on lines 40 to +45
type App struct {
logger *slog.Logger
cfg *config.ONTAP
options Options
locks *lock.Map
catalog catalog.APICatalog
versionCache sync.Map
logger *slog.Logger
cfg *config.ONTAP
options Config
testHTTPClient *http.Client
locks *lock.Map
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

App.testHTTPClient is never set anywhere in the codebase after this refactor, which makes the getClient() branch effectively dead and removes the previous ability to inject an HTTP client via options. Either remove this field/branch, or add an explicit way to set it (e.g., a NewApp parameter/functional option or a setter) so tests and callers can actually use it.

Copilot uses AI. Check for mistakes.
Comment thread server/server.go
Comment on lines +529 to 531
if a.testHTTPClient != nil {
return rest.NewWithClient(poller, a.testHTTPClient), nil
}
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

getClient() checks a.testHTTPClient, but there is no code path that assigns this field after removing Options.TestHTTPClient, so this branch is currently dead. Either wire testHTTPClient through NewApp (or another public API) or remove the branch to avoid confusing future readers.

Suggested change
if a.testHTTPClient != nil {
return rest.NewWithClient(poller, a.testHTTPClient), nil
}

Copilot uses AI. Check for mistakes.
@cgrinds cgrinds closed this Apr 10, 2026
@cgrinds cgrinds deleted the cbg-cli branch April 10, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants