@@ -23,7 +23,7 @@ import (
23
23
24
24
type Config struct {
25
25
Dirs []string
26
- Save string // rename to SaveName
26
+ SaveName string
27
27
Dupes bool
28
28
Export bool
29
29
Log bool
@@ -197,8 +197,8 @@ func (c *Config) WalkDir(root string) error {
197
197
c .saved ++
198
198
}
199
199
}
200
- if c .Save != "" {
201
- dat .name = c .exports .unique (path , c .Save )
200
+ if c .SaveName != "" {
201
+ dat .name = c .exports .unique (path , c .SaveName )
202
202
c .names += len (dat .name )
203
203
if c .save (dat ) {
204
204
c .WriteLog (fmt .Sprintf ("SAVED: %s (%s) << %s" , dat .name , humanize .Bytes (uint64 (len (cmmt ))), path ))
@@ -212,32 +212,33 @@ func (c *Config) WalkDir(root string) error {
212
212
213
213
// clean the syntax of the target export directory path.
214
214
func (c * Config ) clean () error {
215
- if c . Save != "" {
216
- c . Save = filepath .Clean (c . Save )
217
- p := strings .Split (c . Save , string (filepath .Separator ))
215
+ if name := c . SaveName ; name != "" {
216
+ name = filepath .Clean (name )
217
+ p := strings .Split (name , string (filepath .Separator ))
218
218
if p [0 ] == "~" {
219
219
hd , err := os .UserHomeDir ()
220
220
if err != nil {
221
221
return err
222
222
}
223
- c . Save = strings .Replace (c . Save , "~" , hd , 1 )
223
+ name = strings .Replace (name , "~" , hd , 1 )
224
224
}
225
- s , err := os .Stat (c . Save )
225
+ s , err := os .Stat (name )
226
226
if errors .Is (err , fs .ErrInvalid ) {
227
- return fmt .Errorf ("%s: export %w" , c . Save , ErrValid )
227
+ return fmt .Errorf ("%s: export %w" , name , ErrValid )
228
228
}
229
229
if errors .Is (err , fs .ErrNotExist ) {
230
- return fmt .Errorf ("%s: export %w" , c . Save , ErrMissing )
230
+ return fmt .Errorf ("%s: export %w" , name , ErrMissing )
231
231
}
232
232
if errors .Is (err , fs .ErrPermission ) {
233
- return fmt .Errorf ("%s: export %w" , c . Save , ErrPerm )
233
+ return fmt .Errorf ("%s: export %w" , name , ErrPerm )
234
234
}
235
235
if err != nil {
236
- return fmt .Errorf ("%s: export %w" , c . Save , err )
236
+ return fmt .Errorf ("%s: export %w" , name , err )
237
237
}
238
238
if ! s .IsDir () {
239
- return fmt .Errorf ("%s: export %w" , c . Save , ErrIsFile )
239
+ return fmt .Errorf ("%s: export %w" , name , ErrIsFile )
240
240
}
241
+ c .SaveName = name
241
242
}
242
243
return nil
243
244
}
@@ -288,7 +289,7 @@ func (c Config) separator(name string) string {
288
289
// Status summarizes the zip files scan.
289
290
func (c Config ) Status () string {
290
291
if c .Log {
291
- if c .Save != "" {
292
+ if c .SaveName != "" {
292
293
s := fmt .Sprintf ("Saved %d comments from %d finds" , c .saved , c .cmmts )
293
294
c .WriteLog (s )
294
295
}
@@ -314,7 +315,7 @@ func (c Config) Status() string {
314
315
}
315
316
s += color .Secondary .Sprint ("Scanned " ) +
316
317
color .Primary .Sprintf ("%d zip %s" , c .zips , a )
317
- if c .Save != "" && c .saved != c .cmmts {
318
+ if c .SaveName != "" && c .saved != c .cmmts {
318
319
s += color .Secondary .Sprint (", saved " ) +
319
320
color .Primary .Sprintf ("%d text files" , c .saved )
320
321
}
@@ -327,7 +328,7 @@ func (c Config) Status() string {
327
328
return s
328
329
}
329
330
330
- // Save a zip cmmt to the file path.
331
+ // SaveName a zip cmmt to the file path.
331
332
// Unless the overwrite argument is set, any previous cmmt text files are skipped.
332
333
func (c * Config ) save (dat save ) bool {
333
334
// name, cmmt string, mod time.Time, ow bool
@@ -387,7 +388,7 @@ func valid(name string) bool {
387
388
// unique checks the destination path against an export map.
388
389
// The map contains a unique collection of previously used destination
389
390
// paths, to avoid creating duplicate text filenames while using the
390
- // Save config.
391
+ // SaveName config.
391
392
func (e export ) unique (zipPath , dest string ) string {
392
393
base := filepath .Base (zipPath )
393
394
name := strings .TrimSuffix (base , filepath .Ext (base )) + filename
0 commit comments