Skip to content

Commit 63a13b1

Browse files
authored
fix: expose launch set name args directly (#29)
1 parent 2f0458b commit 63a13b1

3 files changed

Lines changed: 69 additions & 16 deletions

File tree

types.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,13 @@ type GlobalArgs struct {
7171
When string `advarg:"when"`
7272
}
7373

74-
// LaunchSetNameArgs contains optional launcher set-name advanced arguments.
75-
type LaunchSetNameArgs struct {
74+
// LaunchArgs contains advanced arguments for the launch command.
75+
type LaunchArgs struct {
76+
GlobalArgs
7677
// SetName specifies a platform-defined launch profile/core name override.
7778
SetName string `advarg:"set_name"`
7879
// SetNameSameDir controls whether SetName should keep the original game directory.
7980
SetNameSameDir string `advarg:"set_name_same_dir"`
80-
}
81-
82-
// LaunchArgs contains advanced arguments for the launch command.
83-
type LaunchArgs struct {
84-
GlobalArgs
85-
LaunchSetNameArgs
8681
// Launcher overrides the default launcher by ID.
8782
Launcher string `advarg:"launcher" validate:"omitempty,launcher"` //nolint:revive // custom validator
8883
// System specifies the target system for path resolution.
@@ -98,7 +93,10 @@ type LaunchArgs struct {
9893
// LaunchRandomArgs contains advanced arguments for the launch.random command.
9994
type LaunchRandomArgs struct {
10095
GlobalArgs
101-
LaunchSetNameArgs
96+
// SetName specifies a platform-defined launch profile/core name override.
97+
SetName string `advarg:"set_name"`
98+
// SetNameSameDir controls whether SetName should keep the original game directory.
99+
SetNameSameDir string `advarg:"set_name_same_dir"`
102100
// Launcher overrides the default launcher by ID.
103101
Launcher string `advarg:"launcher" validate:"omitempty,launcher"` //nolint:revive // custom validator
104102
// Action specifies the launch action (run, details).
@@ -110,7 +108,10 @@ type LaunchRandomArgs struct {
110108
// LaunchSearchArgs contains advanced arguments for the launch.search command.
111109
type LaunchSearchArgs struct {
112110
GlobalArgs
113-
LaunchSetNameArgs
111+
// SetName specifies a platform-defined launch profile/core name override.
112+
SetName string `advarg:"set_name"`
113+
// SetNameSameDir controls whether SetName should keep the original game directory.
114+
SetNameSameDir string `advarg:"set_name_same_dir"`
114115
// Launcher overrides the default launcher by ID.
115116
Launcher string `advarg:"launcher" validate:"omitempty,launcher"` //nolint:revive // custom validator
116117
// Action specifies the launch action (run, details).
@@ -122,7 +123,10 @@ type LaunchSearchArgs struct {
122123
// LaunchTitleArgs contains advanced arguments for the launch.title command.
123124
type LaunchTitleArgs struct {
124125
GlobalArgs
125-
LaunchSetNameArgs
126+
// SetName specifies a platform-defined launch profile/core name override.
127+
SetName string `advarg:"set_name"`
128+
// SetNameSameDir controls whether SetName should keep the original game directory.
129+
SetNameSameDir string `advarg:"set_name_same_dir"`
126130
// Launcher overrides the default launcher by ID.
127131
Launcher string `advarg:"launcher" validate:"omitempty,launcher"` //nolint:revive // custom validator
128132
// Action specifies the launch action (run, details).
@@ -134,7 +138,10 @@ type LaunchTitleArgs struct {
134138
// LaunchLastArgs contains advanced arguments for the launch.last command.
135139
type LaunchLastArgs struct {
136140
GlobalArgs
137-
LaunchSetNameArgs
141+
// SetName specifies a platform-defined launch profile/core name override.
142+
SetName string `advarg:"set_name"`
143+
// SetNameSameDir controls whether SetName should keep the original game directory.
144+
SetNameSameDir string `advarg:"set_name_same_dir"`
138145
// Launcher overrides the default launcher by ID.
139146
Launcher string `advarg:"launcher" validate:"omitempty,launcher"` //nolint:revive // custom validator
140147
// Action specifies the launch action (run, details).

types_advargs_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2026 The Zaparoo Project Contributors.
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
package zapscript
17+
18+
import (
19+
"reflect"
20+
"testing"
21+
)
22+
23+
func TestLaunchArgsSetNameAdvargFields(t *testing.T) {
24+
t.Parallel()
25+
26+
requireAdvargField(t, reflect.TypeOf(LaunchArgs{}), "set_name")
27+
requireAdvargField(t, reflect.TypeOf(LaunchArgs{}), "set_name_same_dir")
28+
requireAdvargField(t, reflect.TypeOf(LaunchRandomArgs{}), "set_name")
29+
requireAdvargField(t, reflect.TypeOf(LaunchRandomArgs{}), "set_name_same_dir")
30+
requireAdvargField(t, reflect.TypeOf(LaunchSearchArgs{}), "set_name")
31+
requireAdvargField(t, reflect.TypeOf(LaunchSearchArgs{}), "set_name_same_dir")
32+
requireAdvargField(t, reflect.TypeOf(LaunchTitleArgs{}), "set_name")
33+
requireAdvargField(t, reflect.TypeOf(LaunchTitleArgs{}), "set_name_same_dir")
34+
requireAdvargField(t, reflect.TypeOf(LaunchLastArgs{}), "set_name")
35+
requireAdvargField(t, reflect.TypeOf(LaunchLastArgs{}), "set_name_same_dir")
36+
}
37+
38+
func requireAdvargField(t *testing.T, typ reflect.Type, tag string) {
39+
t.Helper()
40+
41+
for i := range typ.NumField() {
42+
field := typ.Field(i)
43+
if field.Tag.Get("advarg") == tag {
44+
return
45+
}
46+
}
47+
t.Fatalf("%s missing advarg field %q", typ.Name(), tag)
48+
}

types_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ func TestLaunchArgsSetNameFields(t *testing.T) {
2121
t.Parallel()
2222

2323
args := LaunchArgs{
24-
LaunchSetNameArgs: LaunchSetNameArgs{
25-
SetName: "RA_NES",
26-
SetNameSameDir: "1",
27-
},
24+
SetName: "RA_NES",
25+
SetNameSameDir: "1",
2826
}
2927

3028
if args.SetName != "RA_NES" {

0 commit comments

Comments
 (0)