@@ -53,19 +53,26 @@ var (
53
53
title string
54
54
outputPath string
55
55
56
- targetDirectories = newMapString ()
56
+ targetDirectories = newDirectoryOptions ()
57
57
messageOnlyFromThisFile string
58
58
)
59
59
60
- type mapString map [string ][]parse.ParseOption
60
+ type directoryOption struct {
61
+ directory string
62
+ options []parse.ParseOption
63
+ }
64
+
65
+ type directoryOptions []directoryOption
61
66
62
- func newMapString () mapString {
63
- return mapString (make (map [ string ][]parse. ParseOption ))
67
+ func newDirectoryOptions () directoryOptions {
68
+ return directoryOptions (make ([] directoryOption , 0 ))
64
69
}
65
- func (m mapString ) String () string {
70
+
71
+ func (do directoryOptions ) String () string {
66
72
return ""
67
73
}
68
- func (m mapString ) Set (s string ) error {
74
+
75
+ func (do * directoryOptions ) Set (s string ) error {
69
76
for _ , elem := range strings .Split (s , "," ) {
70
77
pair := strings .Split (elem , "=" )
71
78
if len (pair ) != 2 {
@@ -80,12 +87,13 @@ func (m mapString) Set(s string) error {
80
87
opts = append (opts , parse .ParseService )
81
88
}
82
89
}
83
- m [ pair [0 ]] = opts
90
+ * do = append ( * do , directoryOption { directory : pair [0 ], options : opts })
84
91
}
85
92
return nil
86
93
}
87
- func (m mapString ) Type () string {
88
- return "map[string][]parse.ParseOption"
94
+
95
+ func (do directoryOptions ) Type () string {
96
+ return "[]directoryOption"
89
97
}
90
98
91
99
func init () {
@@ -126,20 +134,20 @@ func CommandFunc(cmd *cobra.Command, args []string) error {
126
134
return err
127
135
}
128
136
} else {
129
- for k , opts := range targetDirectories {
130
- log .Println ("opening" , k )
137
+ for _ , elem := range targetDirectories {
138
+ log .Println ("opening" , elem . directory )
131
139
c1 := filepath .Base (filepath .Dir (messageOnlyFromThisFile ))
132
- c2 := filepath .Base (k )
140
+ c2 := filepath .Base (elem . directory )
133
141
bs := ""
134
142
if c1 == c2 {
135
143
bs = messageOnlyFromThisFile
136
144
log .Println ("message only from this file:" , messageOnlyFromThisFile )
137
145
}
138
- proto , err := parse .ReadDir (k , bs )
146
+ proto , err := parse .ReadDir (elem . directory , bs )
139
147
if err != nil {
140
148
return err
141
149
}
142
- ms , err := proto .Markdown ("" , opts , languageOptions ... )
150
+ ms , err := proto .Markdown ("" , elem . options , languageOptions ... )
143
151
if err != nil {
144
152
return err
145
153
}
0 commit comments