Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cli/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func parseNameFilter(value string) (commands.DeviceFilter, error) {
}

// buildAllocateFilters builds a filters slice from CLI flag values.
func buildAllocateFilters(platform, deviceType string, versions, names []string) ([]commands.DeviceFilter, error) {
func buildAllocateFilters(platform, deviceType string, versions []string, name string) ([]commands.DeviceFilter, error) {
var filters []commands.DeviceFilter

filters = append(filters, commands.DeviceFilter{
Expand All @@ -85,10 +85,10 @@ func buildAllocateFilters(platform, deviceType string, versions, names []string)
filters = append(filters, f)
}

for _, n := range names {
f, err := parseNameFilter(n)
if name != "" {
f, err := parseNameFilter(name)
if err != nil {
return nil, fmt.Errorf("invalid --name %q: %w", n, err)
return nil, fmt.Errorf("invalid --name %q: %w", name, err)
}
filters = append(filters, f)
}
Expand Down
6 changes: 3 additions & 3 deletions cli/filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestParseNameFilter_JustWildcard(t *testing.T) {
}

func TestBuildAllocateFilters_PlatformOnly(t *testing.T) {
filters, err := buildAllocateFilters("ios", "", nil, nil)
filters, err := buildAllocateFilters("ios", "", nil, "")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
Expand All @@ -104,7 +104,7 @@ func TestBuildAllocateFilters_PlatformOnly(t *testing.T) {
}

func TestBuildAllocateFilters_WithType(t *testing.T) {
filters, err := buildAllocateFilters("ios", "real", nil, nil)
filters, err := buildAllocateFilters("ios", "real", nil, "")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
Expand All @@ -117,7 +117,7 @@ func TestBuildAllocateFilters_WithType(t *testing.T) {
}

func TestBuildAllocateFilters_Combined(t *testing.T) {
filters, err := buildAllocateFilters("ios", "real", []string{">=18", "<20"}, []string{"iPhone*"})
filters, err := buildAllocateFilters("ios", "real", []string{">=18", "<20"}, "iPhone*")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
// for remote allocate command
fleetType string
fleetVersions []string
fleetNames []string
fleetName string
fleetWait bool
fleetTimeout int

Expand Down
6 changes: 3 additions & 3 deletions cli/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var remoteAllocateCmd = &cobra.Command{
Short: "Allocate a remote device",
Long: `Allocates a device from the remote fleet matching the given filters.

Flags --version and --name can be specified multiple times (all are ANDed).
Flag --version can be specified multiple times (all are ANDed).

Version supports comparison operators:
--version ">=18" (greater than or equal)
Expand All @@ -54,7 +54,7 @@ Name supports wildcard prefix matching:
return err
}

filters, err := buildAllocateFilters(platform, fleetType, fleetVersions, fleetNames)
filters, err := buildAllocateFilters(platform, fleetType, fleetVersions, fleetName)
if err != nil {
return err
}
Expand Down Expand Up @@ -191,7 +191,7 @@ func init() {
_ = remoteAllocateCmd.MarkFlagRequired("platform")
remoteAllocateCmd.Flags().StringVar(&fleetType, "type", "", "device type (real)")
remoteAllocateCmd.Flags().StringArrayVar(&fleetVersions, "version", nil, "OS version filter (supports >=, >, <=, < prefixes)")
remoteAllocateCmd.Flags().StringArrayVar(&fleetNames, "name", nil, "device name filter (supports trailing * for prefix match)")
remoteAllocateCmd.Flags().StringVar(&fleetName, "name", "", "device name filter (supports trailing * for prefix match)")
remoteAllocateCmd.Flags().BoolVar(&fleetWait, "wait", false, "wait for device to finish allocating before returning")
remoteAllocateCmd.Flags().IntVar(&fleetTimeout, "timeout", 900, "seconds to wait for allocation (only used with --wait)")

Expand Down
Loading