github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/cmd/state-svc/app/app.go (about) 1 package app 2 3 import ( 4 "github.com/ActiveState/cli/internal/app" 5 "github.com/ActiveState/cli/internal/constants" 6 "github.com/ActiveState/cli/internal/errs" 7 "github.com/ActiveState/cli/internal/installation" 8 ) 9 10 var Options = app.Options{} 11 12 func NewFromDir(dir string) (*app.App, error) { 13 svcExec, err := installation.ServiceExecFromDir(dir) 14 if err != nil { 15 return nil, errs.Wrap(err, "Could not determine service executable") 16 } 17 18 installRoot, err := installation.InstallRoot(dir) 19 if err != nil { 20 return nil, errs.Wrap(err, "Could not determine install root") 21 } 22 23 return app.New(constants.SvcAppName, svcExec, []string{"start"}, installRoot, Options) 24 } 25 26 func New() (*app.App, error) { 27 svcExec, err := installation.ServiceExec() 28 if err != nil { 29 return nil, errs.Wrap(err, "Could not determine service executable") 30 } 31 32 installRoot, err := installation.InstallPathFromExecPath() 33 if err != nil { 34 return nil, errs.Wrap(err, "Could not determine install root from exec") 35 } 36 37 return app.New(constants.SvcAppName, svcExec, []string{"start"}, installRoot, Options) 38 }