diff --git a/activestate.yaml b/activestate.yaml index b8c1bb2291..8952cb8ccb 100644 --- a/activestate.yaml +++ b/activestate.yaml @@ -1,4 +1,4 @@ -project: https://platform.activestate.com/ActiveState/cli?commitID=96e72fc8-c86d-4f86-b8c7-6fcb393f3941 +project: https://platform.activestate.com/ActiveState/cli?branch=main&commitID=96e72fc8-c86d-4f86-b8c7-6fcb393f3941 constants: - name: CLI_BUILDFLAGS value: -ldflags="-s -w" diff --git a/internal/runners/packages/info.go b/internal/runners/packages/info.go index 816593ceb7..47e6daa9f9 100644 --- a/internal/runners/packages/info.go +++ b/internal/runners/packages/info.go @@ -38,11 +38,7 @@ func NewInfo(prime primeable) *Info { func (i *Info) Run(params InfoRunParams, nstype model.NamespaceType) error { logging.Debug("ExecuteInfo") - if i.proj == nil { - return locale.NewInputError("err_no_project") - } - - language, err := targetedLanguage(params.Language, i.proj.CommitUUID()) + language, err := targetedLanguage(params.Language, i.proj) if err != nil { return locale.WrapError(err, fmt.Sprintf("%s_err_cannot_obtain_language", nstype)) diff --git a/internal/runners/packages/search.go b/internal/runners/packages/search.go index f8b666b1c3..b538d8adc2 100644 --- a/internal/runners/packages/search.go +++ b/internal/runners/packages/search.go @@ -11,7 +11,6 @@ import ( "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/pkg/platform/model" "github.com/ActiveState/cli/pkg/project" - "github.com/go-openapi/strfmt" ) // SearchRunParams tracks the info required for running search. @@ -39,11 +38,7 @@ func NewSearch(prime primeable) *Search { func (s *Search) Run(params SearchRunParams, nstype model.NamespaceType) error { logging.Debug("ExecuteSearch") - if s.proj == nil { - return locale.NewInputError("err_no_project") - } - - language, err := targetedLanguage(params.Language, s.proj.CommitUUID()) + language, err := targetedLanguage(params.Language, s.proj) if err != nil { return locale.WrapError(err, fmt.Sprintf("%s_err_cannot_obtain_language", nstype)) } @@ -72,12 +67,18 @@ func (s *Search) Run(params SearchRunParams, nstype model.NamespaceType) error { return nil } -func targetedLanguage(languageOpt string, commitUUID strfmt.UUID) (string, error) { +func targetedLanguage(languageOpt string, proj *project.Project) (string, error) { if languageOpt != "" { return languageOpt, nil } + if proj == nil { + return "", locale.NewInputError( + "err_no_language_derived", + "Language must be provided by flag or by running this command within a project.", + ) + } - return model.LanguageForCommit(commitUUID) + return model.LanguageForCommit(proj.CommitUUID()) } type modules []string