Skip to content

Commit 03b02fb

Browse files
committed
fix tests and comment
1 parent 54916b0 commit 03b02fb

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

cmd/cmd_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func TestExecute(t *testing.T) {
113113
down: func() { os.Unsetenv(envKeyCommandFormat) },
114114
},
115115
{
116-
name: "tar with remove format",
116+
name: "tar and open url with ctrl mod key",
117117
args: args{
118118
command: "tar",
119119
filepath: testdataPath("test_output_tar_with_ctrl_mod_key.json"),
@@ -496,6 +496,14 @@ func Test_choicePlatform(t *testing.T) {
496496
},
497497
want: tldr.PlatformCommon,
498498
},
499+
{
500+
name: "returns commond when empty pts",
501+
args: args{
502+
pts: []tldr.Platform{},
503+
selected: tldr.PlatformCommon,
504+
},
505+
want: tldr.PlatformCommon,
506+
},
499507
}
500508
for _, tt := range tests {
501509
t.Run(tt.name, func(t *testing.T) {

cmd/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
type envs struct {
99
formatFunc func(string) string
10-
openURLModKey alfred.ModKey
10+
modKeyOpenURL alfred.ModKey
1111
isUpdateWorkflowRecommendEnabled bool
1212
isUpdateDBRecommendEnabled bool
1313
}
@@ -27,7 +27,7 @@ type config struct {
2727
func newConfig() *config {
2828
cfg := new(config)
2929
cfg.fromEnv.formatFunc = getCommandFormatFunc()
30-
cfg.fromEnv.openURLModKey = getOpenURLMod()
30+
cfg.fromEnv.modKeyOpenURL = getModKeyOpenURL()
3131
cfg.fromEnv.isUpdateDBRecommendEnabled = isUpdateDBRecommendEnabled()
3232
cfg.fromEnv.isUpdateWorkflowRecommendEnabled = isUpdateWorkflowRecommendEnabled()
3333
return cfg

cmd/print.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (cfg *config) printPage(cmds []string) error {
6969
}
7070

7171
awf.Append(
72-
makeDescriptionItem(p, cfg.fromEnv.openURLModKey),
72+
makeDescriptionItem(p, cfg.fromEnv.modKeyOpenURL),
7373
)
7474
for _, cmd := range p.CmdExamples {
7575
command := cfg.fromEnv.formatFunc(cmd.Cmd)
@@ -85,7 +85,7 @@ func (cfg *config) printPage(cmds []string) error {
8585
return nil
8686
}
8787

88-
func makeDescriptionItem(p *tldr.Page, openURLModKey alfred.ModKey) *alfred.Item {
88+
func makeDescriptionItem(p *tldr.Page, modKey alfred.ModKey) *alfred.Item {
8989
// Note descriptions has one line at least
9090
// see: https://github.com/tldr-pages/tldr/blob/master/contributing-guides/style-guide.md
9191
title := p.CmdDescriptions[0]
@@ -94,15 +94,15 @@ func makeDescriptionItem(p *tldr.Page, openURLModKey alfred.ModKey) *alfred.Item
9494
subtitle = p.CmdDescriptions[1]
9595
}
9696

97-
mod := alfred.NewMod()
97+
openMod := alfred.NewMod()
9898
u, err := parseDetailURL(p.CmdDescriptions)
9999
if err != nil {
100100
awf.Logger().Warnln(err)
101-
mod.
101+
openMod.
102102
Valid(false).
103103
Subtitle("no action")
104104
} else {
105-
mod.
105+
openMod.
106106
Arg(u).
107107
Subtitle("open more information url").
108108
Variable(nextActionKey, nextActionOpenURL)
@@ -116,7 +116,7 @@ func makeDescriptionItem(p *tldr.Page, openURLModKey alfred.ModKey) *alfred.Item
116116
alfred.NewIcon().
117117
Path("description.png"),
118118
).
119-
Mod(openURLModKey, mod)
119+
Mod(modKey, openMod)
120120
}
121121

122122
func (cfg *config) printFuzzyPages(cmds []string) error {
@@ -179,7 +179,7 @@ func choicePlatform(pts []tldr.Platform, selected tldr.Platform) tldr.Platform {
179179
}
180180
}
181181

182-
// Note: unexpected case, we assume one pts at least but if zero return common
182+
// Note: unexpected case, we assume one platform in pts at least but if empty, return common
183183
if len(pts) == 0 {
184184
return tldr.PlatformCommon
185185
}

cmd/workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func init() {
5353
}
5454
}
5555

56-
func getOpenURLMod() alfred.ModKey {
56+
func getModKeyOpenURL() alfred.ModKey {
5757
v := os.Getenv(envKeyOpenURLMod)
5858
switch v {
5959
case "alt":

doc/CONFIGURATION.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ The workflow provides some configurations via [workflow environment variables](h
44

55
### Open URL Modifier Key
66

7-
`TLDR_MOD_KEY_OPEN_URL` is variable that configures to open detail command url with default web browser.
7+
`TLDR_MOD_KEY_OPEN_URL` is variable that configures keys to open detail command url with web browser.
88

9-
By default, you can open url with pressing `cmd` + `enter` if a specified command has related URL.
9+
By default, you can open url with pressing `cmd(⌘)` + `enter` if a specified command has related URL.
1010

1111
Available variables are the followings
1212

@@ -16,7 +16,7 @@ Available variables are the followings
1616
- `fn`
1717
- `shift`
1818

19-
For example, if you specified `ctrl` for `TLDR_MOD_KEY_OPEN_URL`, you can open url with pressing `ctrl` + `enter`.
19+
For example, if you specified `ctrl` for `TLDR_MOD_KEY_OPEN_URL`, you can open url with pressing `ctrl(^)` + `enter`.
2020

2121
### Command Format
2222

0 commit comments

Comments
 (0)