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:
@@ -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"}
|
||||
|
||||
Reference in New Issue
Block a user