refactor: remove service factory wrappers, call store init methods directly

Replace InitNodeService/GetNodeService/GetNodeServiceForUser with thin
NewLocalNodeService/NewRemoteNodeService constructors; move wiring logic
into cmd/root.go (getNodeService helper) and an inline closure in serve.go.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-02 00:56:45 +02:00
parent 03a896d23f
commit 51341eeb84
10 changed files with 37 additions and 40 deletions
+16
View File
@@ -11,6 +11,22 @@ import (
"github.com/spf13/cobra"
)
func getNodeService() (service.NodeService, error) {
user := cfg.GetUser()
if user == "" {
return nil, fmt.Errorf("no user configured: run 'ax user set <username>' first")
}
if rc, ok := cfg.GetRemoteConfig(); ok {
base := fmt.Sprintf("http://%s:%d", rc.Host, rc.Port)
return service.NewRemoteNodeService(base, user), nil
}
st, err := store.FindAndOpenSQLiteStore()
if err != nil {
return nil, err
}
return service.NewLocalNodeService(st, user), nil
}
var jsonFlag bool
var cfg *store.Config
var rootCmd = &cobra.Command{Use: "ax", Short: "The axolotl issue tracker"}