Skip to content

Commit

Permalink
fix: report error if selections are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Saidl committed Oct 3, 2024
1 parent b657844 commit b6dbe23
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v1.0.27] - 2024-10-03

### Fixed
- report error if selections are empty

## [v1.0.26] - 2024-09-10

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ at https://docs.zerops.io/references/cli for further details.`,
ProjectSelectorListEmpty: "You don't have any projects yet. Create a new project using `zcli project import` command.",
ProjectSelectorPrompt: "Please, select a project",
ProjectSelectorOutOfRangeError: "We couldn't find a project with the index you entered. Please, try again or contact our support team.",
ServiceSelectorListEmpty: "Project doesn't have any services yet. Create a new service using `zcli service import` command",
ServiceSelectorListEmpty: "Project doesn't have any services yet. Create a new service using `zcli project service-import` command",
ServiceSelectorPrompt: "Please, select a service",
ServiceSelectorOutOfRangeError: "We couldn't find a service with the index you entered. Please, try again or contact our support team.",
OrgSelectorListEmpty: "You don't belong to any organization yet. Please, contact our support team.",
Expand Down
4 changes: 1 addition & 3 deletions src/uxHelpers/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/zeropsio/zcli/src/entity/repository"
"github.com/zeropsio/zcli/src/i18n"
"github.com/zeropsio/zcli/src/uxBlock"
"github.com/zeropsio/zcli/src/uxBlock/styles"
"github.com/zeropsio/zcli/src/zeropsRestApiClient"
)

Expand All @@ -23,8 +22,7 @@ func PrintOrgSelector(
}

if len(orgs) == 0 {
uxBlocks.PrintWarning(styles.WarningLine(i18n.T(i18n.OrgSelectorListEmpty)))
return nil, nil
return nil, errors.New(i18n.T(i18n.OrgSelectorListEmpty))
}

header, tableBody := createOrgTableRows(orgs)
Expand Down
4 changes: 1 addition & 3 deletions src/uxHelpers/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/zeropsio/zcli/src/entity/repository"
"github.com/zeropsio/zcli/src/i18n"
"github.com/zeropsio/zcli/src/uxBlock"
"github.com/zeropsio/zcli/src/uxBlock/styles"
"github.com/zeropsio/zcli/src/zeropsRestApiClient"
)

Expand All @@ -23,8 +22,7 @@ func PrintProjectSelector(
}

if len(projects) == 0 {
uxBlocks.PrintWarning(styles.WarningLine(i18n.T(i18n.ProjectSelectorListEmpty)))
return nil, nil
return nil, errors.New(i18n.T(i18n.ProjectSelectorPrompt))
}

header, tableBody := createProjectTableRows(projects)
Expand Down
4 changes: 1 addition & 3 deletions src/uxHelpers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/zeropsio/zcli/src/entity/repository"
"github.com/zeropsio/zcli/src/i18n"
"github.com/zeropsio/zcli/src/uxBlock"
"github.com/zeropsio/zcli/src/uxBlock/styles"
"github.com/zeropsio/zcli/src/zeropsRestApiClient"
)

Expand All @@ -24,8 +23,7 @@ func PrintServiceSelector(
}

if len(services) == 0 {
uxBlocks.PrintWarning(styles.WarningLine(i18n.T(i18n.ServiceSelectorListEmpty)))
return nil, nil
return nil, errors.New(i18n.T(i18n.ServiceSelectorListEmpty))
}

header, rows := createServiceTableRows(services)
Expand Down

0 comments on commit b6dbe23

Please sign in to comment.