Skip to content

Commit 9b14a8c

Browse files
committed
Remove double namespacing from alfred ns
Much more conventional to have alfred.Item instead of alfred.alfredItem
1 parent bb4a1b6 commit 9b14a8c

File tree

2 files changed

+73
-73
lines changed

2 files changed

+73
-73
lines changed

alfred/alfred.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@ import (
55
"fmt"
66
)
77

8-
type AlfredIcon struct {
8+
type Icon struct {
99
Type string `json:"type,omitempty"`
1010
Path string `json:"path,omitempty"`
1111
}
1212

13-
type AlfredMod struct {
13+
type Mod struct {
1414
Valid bool `json:"valid,omitempty"`
1515
Arg string `json:"arg,omitempty"`
1616
Subtitle string `json:"subtitle,omitempty"`
1717
}
1818

19-
type AlfredMods struct {
20-
Ctrl AlfredMod `json:"ctrl,omitempty"`
21-
Alt AlfredMod `json:"alt,omitempty"`
22-
Cmd AlfredMod `json:"cmd,omitempty"`
19+
type Mods struct {
20+
Ctrl Mod `json:"ctrl,omitempty"`
21+
Alt Mod `json:"alt,omitempty"`
22+
Cmd Mod `json:"cmd,omitempty"`
2323
}
2424

25-
type AlfredItem struct {
26-
Uid string `json:"uid,omitempty"`
27-
Type string `json:"type,omitempty"`
28-
Title string `json:"title,omitempty"`
29-
Subtitle string `json:"subtitle,omitempty"`
30-
Arg string `json:"arg,omitempty"`
31-
Autocomplete string `json:"autocomplete,omitempty"`
32-
Valid *bool `json:"valid,omitempty"`
33-
Icon AlfredIcon `json:"icon,omitempty"`
34-
Mods AlfredMods `json:"mods,omitempty"`
25+
type Item struct {
26+
Uid string `json:"uid,omitempty"`
27+
Type string `json:"type,omitempty"`
28+
Title string `json:"title,omitempty"`
29+
Subtitle string `json:"subtitle,omitempty"`
30+
Arg string `json:"arg,omitempty"`
31+
Autocomplete string `json:"autocomplete,omitempty"`
32+
Valid *bool `json:"valid,omitempty"`
33+
Icon Icon `json:"icon,omitempty"`
34+
Mods Mods `json:"mods,omitempty"`
3535
}
3636

37-
type AlfredItems struct {
38-
Items []AlfredItem `json:"items"`
37+
type Items struct {
38+
Items []Item `json:"items"`
3939
}
4040

41-
func PrintMenu(items AlfredItems) error {
41+
func PrintMenu(items Items) error {
4242
itemsBytes, err := json.Marshal(items)
4343

4444
if err != nil {

menus/menus.go

+54-54
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ const (
1414
)
1515

1616
func SetupAuthMenu() error {
17-
items := alfred.AlfredItems{
18-
Items: []alfred.AlfredItem{
19-
alfred.AlfredItem{
17+
items := alfred.Items{
18+
Items: []alfred.Item{
19+
alfred.Item{
2020
Title: "Authenticate to Spot",
21-
Icon: alfred.AlfredIcon{
21+
Icon: alfred.Icon{
2222
Path: "icons/configuration.png",
2323
},
2424
Valid: newFalse(),
@@ -31,9 +31,9 @@ func SetupAuthMenu() error {
3131
}
3232

3333
func ClientIdMenuInstruction() error {
34-
items := alfred.AlfredItems{
35-
Items: []alfred.AlfredItem{
36-
alfred.AlfredItem{
34+
items := alfred.Items{
35+
Items: []alfred.Item{
36+
alfred.Item{
3737
Title: "Paste the Client Id above and press enter",
3838
},
3939
},
@@ -43,9 +43,9 @@ func ClientIdMenuInstruction() error {
4343
}
4444

4545
func ClientIdMenuStepFinished() error {
46-
items := alfred.AlfredItems{
47-
Items: []alfred.AlfredItem{
48-
alfred.AlfredItem{
46+
items := alfred.Items{
47+
Items: []alfred.Item{
48+
alfred.Item{
4949
Title: "The client id is set, press enter to close",
5050
},
5151
},
@@ -55,9 +55,9 @@ func ClientIdMenuStepFinished() error {
5555
}
5656

5757
func ClientSecretMenuInstruction() error {
58-
items := alfred.AlfredItems{
59-
Items: []alfred.AlfredItem{
60-
alfred.AlfredItem{
58+
items := alfred.Items{
59+
Items: []alfred.Item{
60+
alfred.Item{
6161
Title: "Paste the Client Secret above and press enter",
6262
},
6363
},
@@ -67,9 +67,9 @@ func ClientSecretMenuInstruction() error {
6767
}
6868

6969
func ClientSecretMenuStepFinished() error {
70-
items := alfred.AlfredItems{
71-
Items: []alfred.AlfredItem{
72-
alfred.AlfredItem{
70+
items := alfred.Items{
71+
Items: []alfred.Item{
72+
alfred.Item{
7373
Title: "Setup is now complete! Press enter to close",
7474
},
7575
},
@@ -85,29 +85,29 @@ func StatusMenu(spotifyStatus spotify.Status) error {
8585
playerStatusIcon = "icons/paused.png"
8686
}
8787

88-
items := alfred.AlfredItems{
89-
Items: []alfred.AlfredItem{
90-
alfred.AlfredItem{
88+
items := alfred.Items{
89+
Items: []alfred.Item{
90+
alfred.Item{
9191
Title: spotifyStatus.SongTitle,
9292
Subtitle: fmt.Sprintf("%s by %s", spotifyStatus.Album, spotifyStatus.Artist),
9393
Arg: "-action playpause",
94-
Icon: alfred.AlfredIcon{
94+
Icon: alfred.Icon{
9595
Path: playerStatusIcon,
9696
},
9797
},
98-
alfred.AlfredItem{
98+
alfred.Item{
9999
Title: spotifyStatus.Artist,
100100
Subtitle: "More from this artist...",
101-
Icon: alfred.AlfredIcon{
101+
Icon: alfred.Icon{
102102
Path: "icons/artist.png",
103103
},
104104
Valid: newFalse(),
105105
Autocomplete: fmt.Sprintf("-artist=\"%s\" ", spotifyStatus.Artist),
106106
},
107-
alfred.AlfredItem{
107+
alfred.Item{
108108
Title: spotifyStatus.Album,
109109
Subtitle: "More from this album...",
110-
Icon: alfred.AlfredIcon{
110+
Icon: alfred.Icon{
111111
Path: "icons/album.png",
112112
},
113113
Valid: newFalse(),
@@ -127,27 +127,27 @@ func ControlsMenu(spotifyStatus spotify.Status) error {
127127
playerStatusIcon = "icons/paused.png"
128128
}
129129

130-
items := alfred.AlfredItems{
131-
Items: []alfred.AlfredItem{
132-
alfred.AlfredItem{
130+
items := alfred.Items{
131+
Items: []alfred.Item{
132+
alfred.Item{
133133
Title: "Next Track",
134134
Arg: "--action next",
135-
Icon: alfred.AlfredIcon{
135+
Icon: alfred.Icon{
136136
Path: "icons/next.png",
137137
},
138138
},
139-
alfred.AlfredItem{
139+
alfred.Item{
140140
Title: "Previous Track",
141141
Arg: "--action previous",
142-
Icon: alfred.AlfredIcon{
142+
Icon: alfred.Icon{
143143
Path: "icons/previous.png",
144144
},
145145
},
146-
alfred.AlfredItem{
146+
alfred.Item{
147147
Title: spotifyStatus.SongTitle,
148148
Subtitle: fmt.Sprintf("%s by %s", spotifyStatus.Album, spotifyStatus.Artist),
149149
Arg: "--action playpause",
150-
Icon: alfred.AlfredIcon{
150+
Icon: alfred.Icon{
151151
Path: playerStatusIcon,
152152
},
153153
},
@@ -169,31 +169,31 @@ func popularityToMeter(popularity int) string {
169169
return meter
170170
}
171171

172-
func albumItem(album client.SimpleAlbum) alfred.AlfredItem {
173-
return alfred.AlfredItem{
172+
func albumItem(album client.SimpleAlbum) alfred.Item {
173+
return alfred.Item{
174174
Uid: string(album.URI),
175175
Title: album.Name,
176176
Valid: newFalse(),
177177
Autocomplete: fmt.Sprintf("-album=\"%s\" ", album.Name),
178-
Icon: alfred.AlfredIcon{
178+
Icon: alfred.Icon{
179179
Path: "icons/album.png",
180180
},
181-
Mods: alfred.AlfredMods{
182-
Ctrl: alfred.AlfredMod{
181+
Mods: alfred.Mods{
182+
Ctrl: alfred.Mod{
183183
Arg: fmt.Sprintf("--action revealinspotify --context %s", album.URI),
184184
Subtitle: "Reveal in Spotify",
185185
},
186186
},
187187
}
188188
}
189189

190-
func albumItemWithArtist(album client.SimpleAlbum, artist string) alfred.AlfredItem {
190+
func albumItemWithArtist(album client.SimpleAlbum, artist string) alfred.Item {
191191
item := albumItem(album)
192192
item.Autocomplete = fmt.Sprintf("-artist=\"%s\" -album=\"%s\" ", artist, album.Name)
193193
return item
194194
}
195195

196-
func trackItem(track client.FullTrack, contextType int) alfred.AlfredItem {
196+
func trackItem(track client.FullTrack, contextType int) alfred.Item {
197197
var arg string
198198
if contextType == albumContext {
199199
arg = fmt.Sprintf("--action playtrack --track %s --context %s", track.URI, track.Album.URI)
@@ -203,35 +203,35 @@ func trackItem(track client.FullTrack, contextType int) alfred.AlfredItem {
203203
arg = fmt.Sprintf("--action playtrack --track %s", track.URI)
204204
}
205205

206-
return alfred.AlfredItem{
206+
return alfred.Item{
207207
Uid: string(track.URI),
208208
Title: track.Name,
209209
Subtitle: popularityToMeter(track.Popularity),
210-
Icon: alfred.AlfredIcon{
210+
Icon: alfred.Icon{
211211
Path: "icons/track.png",
212212
},
213213
Arg: arg,
214-
Mods: alfred.AlfredMods{
215-
Ctrl: alfred.AlfredMod{
214+
Mods: alfred.Mods{
215+
Ctrl: alfred.Mod{
216216
Arg: fmt.Sprintf("--action revealinspotify --context %s", track.URI),
217217
Subtitle: "Reveal in Spotify",
218218
},
219219
},
220220
}
221221
}
222222

223-
func artistItem(artist client.FullArtist) alfred.AlfredItem {
224-
return alfred.AlfredItem{
223+
func artistItem(artist client.FullArtist) alfred.Item {
224+
return alfred.Item{
225225
Uid: string(artist.URI),
226226
Title: artist.Name,
227227
Subtitle: popularityToMeter(artist.Popularity),
228-
Icon: alfred.AlfredIcon{
228+
Icon: alfred.Icon{
229229
Path: "icons/artist.png",
230230
},
231231
Valid: newFalse(),
232232
Autocomplete: fmt.Sprintf("-artist=\"%s\" ", artist.Name),
233-
Mods: alfred.AlfredMods{
234-
Ctrl: alfred.AlfredMod{
233+
Mods: alfred.Mods{
234+
Ctrl: alfred.Mod{
235235
Arg: fmt.Sprintf("--action revealinspotify --context %s", artist.URI),
236236
Subtitle: "Reveal in Spotify",
237237
},
@@ -252,14 +252,14 @@ func AlbumDetailMenu(album string, args []string) error {
252252
}
253253

254254
tracks := searchResults.Tracks.Tracks
255-
items := make([]alfred.AlfredItem, 0, len(tracks))
255+
items := make([]alfred.Item, 0, len(tracks))
256256

257257
for _, track := range tracks {
258258
items = append(items, trackItem(track, albumContext))
259259

260260
}
261261

262-
alfredItems := alfred.AlfredItems{
262+
alfredItems := alfred.Items{
263263
Items: items,
264264
}
265265

@@ -280,7 +280,7 @@ func ArtistDetailMenu(artist string, args []string) error {
280280

281281
albums := searchResults.Albums.Albums
282282
tracks := searchResults.Tracks.Tracks
283-
items := make([]alfred.AlfredItem, 0, len(albums)+len(tracks))
283+
items := make([]alfred.Item, 0, len(albums)+len(tracks))
284284

285285
for _, track := range tracks {
286286
items = append(items, trackItem(track, artistContext))
@@ -292,7 +292,7 @@ func ArtistDetailMenu(artist string, args []string) error {
292292

293293
}
294294

295-
alfredItems := alfred.AlfredItems{
295+
alfredItems := alfred.Items{
296296
Items: items,
297297
}
298298

@@ -314,7 +314,7 @@ func SearchMenu(args []string) error {
314314
albums := searchResults.Albums.Albums
315315
tracks := searchResults.Tracks.Tracks
316316
artists := searchResults.Artists.Artists
317-
items := make([]alfred.AlfredItem, 0, len(albums)+len(tracks)+len(artists))
317+
items := make([]alfred.Item, 0, len(albums)+len(tracks)+len(artists))
318318

319319
for _, track := range tracks {
320320
items = append(items, trackItem(track, artistContext))
@@ -331,7 +331,7 @@ func SearchMenu(args []string) error {
331331

332332
}
333333

334-
alfredItems := alfred.AlfredItems{
334+
alfredItems := alfred.Items{
335335
Items: items,
336336
}
337337

0 commit comments

Comments
 (0)