cli/pkg/docs/docs.go
Snider 41a0faba75 refactor: migrate module path from Snider/Core to host-uk/core
Move Go module from github.com/Snider/Core to github.com/host-uk/core
to match the new repository location under the host-uk organization.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 15:29:42 +00:00

58 lines
1.3 KiB
Go

// Package docs provides documentation window management.
package docs
import (
"github.com/host-uk/core/pkg/core"
"github.com/host-uk/core/pkg/display"
)
// Service manages documentation windows.
type Service struct {
core *core.Core
baseURL string
}
// Options configures the docs service.
type Options struct {
BaseURL string
}
// New creates a new docs service.
func New(opts Options) (*Service, error) {
return &Service{
baseURL: opts.BaseURL,
}, nil
}
// SetCore sets the core reference for accessing other services.
func (s *Service) SetCore(c *core.Core) {
s.core = c
}
// SetBaseURL sets the base URL for documentation.
func (s *Service) SetBaseURL(url string) {
s.baseURL = url
}
// OpenDocsWindow opens a documentation window at the specified path.
// The path is appended to the base URL to form the full documentation URL.
func (s *Service) OpenDocsWindow(path string) error {
url := s.baseURL
if path != "" {
if url != "" && url[len(url)-1] != '/' && path[0] != '/' {
url += "/"
}
url += path
}
// Fire an ACTION to request a window from the display service
return s.core.ACTION(display.ActionOpenWindow{
WebviewWindowOptions: display.Window{
Name: "docs-window",
Title: "Documentation",
URL: url,
Width: 1200,
Height: 800,
},
})
}