Skip to content

Commit e61df9e

Browse files
committed
[fix] upper letter URL compatible problem
1 parent f55f924 commit e61df9e

6 files changed

Lines changed: 58 additions & 7 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
.idea
1+
.idea
2+
config.yaml
3+
goto

alfred/const.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package alfred
2+
3+
type Item struct {
4+
Title string `json:"title"`
5+
Valid bool `json:"valid,omitempty"`
6+
UID string `json:"uid,omitempty"`
7+
Type string `json:"type,omitempty"`
8+
Subtitle string `json:"subtitle,omitempty"`
9+
Arg string `json:"arg,omitempty"`
10+
Autocomplete string `json:"autocomplete,omitempty"`
11+
QuickLookURL string `json:"quicklookurl,omitempty"`
12+
Icon *Icon `json:"icon,omitempty"`
13+
Text *Text `json:"text,omitempty"`
14+
Mods map[string]*Mod `json:"mods,omitempty"`
15+
Variables map[string]string `json:"variables,omitempty"` //From Alfred 3.4.1
16+
}
17+
18+
type Icon struct {
19+
Type string `json:"type,omitempty"`
20+
Path string `json:"path"`
21+
}
22+
23+
type Text struct {
24+
Copy string `json:"copy,omitempty"`
25+
LargeType string `json:"largetype,omitempty"`
26+
}
27+
28+
type Mod struct {
29+
Valid bool `json:"valid"`
30+
Arg string `json:"arg"`
31+
Subtitle string `json:"subtitle"`
32+
Icon *Icon `json:"icon,omitempty"` //From Alfred 3.4.1
33+
Variables map[string]string `json:"variables,omitempty"` //From Alfred 3.4.1
34+
}

alfred/output.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package alfred
2+
3+
func NewSimpleItem(title, subTitle, arg, autoComplete string) *Item {
4+
return &Item{
5+
Title: title,
6+
Subtitle: subTitle,
7+
Arg: arg,
8+
Autocomplete: autoComplete,
9+
}
10+
}

config/config.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func GetConfigPath() string {
3939
}
4040

4141
func NewNest(configPath string) (*Nest, error) {
42-
conf, err := loadYaml(configPath)
42+
conf, err := loadConfig(configPath)
4343
if err != nil {
4444
return nil, err
4545
}
@@ -51,7 +51,7 @@ func (n *Nest) GetScalar(paths []string) (URL string, ok bool) {
5151
}
5252

5353
func (n *Nest) Flush() error {
54-
return writeYaml(GetConfigPath(), n.Data)
54+
return writeConfig(GetConfigPath(), n.Data)
5555
}
5656

5757
func (n *Nest) AddScalar(paths []string, url string) {
@@ -70,7 +70,7 @@ func typeOf(i interface{}) ModelType {
7070
}
7171

7272
//load config from yaml
73-
func loadYaml(path string) (conf map[string]interface{}, err error) {
73+
func loadConfig(path string) (conf map[string]interface{}, err error) {
7474
f, err := ioutil.ReadFile(path)
7575
if err != nil {
7676
return nil, err
@@ -87,7 +87,7 @@ func loadYaml(path string) (conf map[string]interface{}, err error) {
8787
}
8888

8989
//put the config into yaml file
90-
func writeYaml(path string, target interface{}) error {
90+
func writeConfig(path string, target interface{}) error {
9191
out, err := yaml.Marshal(target)
9292
if err != nil {
9393
return err
@@ -174,7 +174,7 @@ func toLower(m map[string]interface{}) map[string]interface{} {
174174
delete(m, k)
175175
switch typeOf(v) {
176176
case TypeScalar:
177-
v = strings.ToLower(v.(string))
177+
//scalar do not need to be lower
178178
case TypeVector:
179179
v = toLower(v.(map[string]interface{}))
180180
default:

handler/get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ func Get(args []string) {
1414
}
1515
url, ok := nest.GetScalar(args)
1616
if !ok {
17+
log.Println("%+v not found", args)
1718
return
1819
}
1920
cmd := exec.Command("open", url)
2021
err = cmd.Run()
2122
if err != nil {
2223
log.Fatal(err.Error())
23-
2424
}
2525
}

handler/list.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package handler
2+
3+
func List(args []string) {
4+
5+
}

0 commit comments

Comments
 (0)