First start: create the config file and open the Config view
Without a config file arr-tui refused to start. It now creates an empty one (private, with its directory) and opens the Config view. A service with neither address nor key is "not configured", which validation allows: its client returns ErrNotConfigured without a request, its indicator stays grey, it is logged once as information, and its lists say so instead of showing errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019reK4DUGYqDUjniWYJvwUW
This commit is contained in:
@@ -40,6 +40,10 @@ func NewClient(baseURL, apiKey string) *Client {
|
||||
}
|
||||
}
|
||||
|
||||
// ErrNotConfigured is returned without a request while the client has no
|
||||
// address: the service is not set up.
|
||||
var ErrNotConfigured = errors.New("not configured: enter its address and API key in the Config view (F6)")
|
||||
|
||||
// Number is a float that SABnzbd sends either as a JSON number or as a string ("0.48").
|
||||
type Number float64
|
||||
|
||||
@@ -172,6 +176,9 @@ func (c *Client) call(ctx context.Context, params url.Values, out any) error {
|
||||
c.mu.RLock()
|
||||
baseURL, apiKey := c.baseURL, c.apiKey
|
||||
c.mu.RUnlock()
|
||||
if baseURL == "" {
|
||||
return ErrNotConfigured
|
||||
}
|
||||
params.Set("apikey", apiKey)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, baseURL+"/api?"+params.Encode(), nil)
|
||||
|
||||
Reference in New Issue
Block a user