@@ -23,7 +23,7 @@ import (
2323
2424type Config struct {
2525 Dirs []string
26- Save string // rename to SaveName
26+ SaveName string
2727 Dupes bool
2828 Export bool
2929 Log bool
@@ -197,8 +197,8 @@ func (c *Config) WalkDir(root string) error {
197197 c .saved ++
198198 }
199199 }
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 )
202202 c .names += len (dat .name )
203203 if c .save (dat ) {
204204 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 {
212212
213213// clean the syntax of the target export directory path.
214214func (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 ))
218218 if p [0 ] == "~" {
219219 hd , err := os .UserHomeDir ()
220220 if err != nil {
221221 return err
222222 }
223- c . Save = strings .Replace (c . Save , "~" , hd , 1 )
223+ name = strings .Replace (name , "~" , hd , 1 )
224224 }
225- s , err := os .Stat (c . Save )
225+ s , err := os .Stat (name )
226226 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 )
228228 }
229229 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 )
231231 }
232232 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 )
234234 }
235235 if err != nil {
236- return fmt .Errorf ("%s: export %w" , c . Save , err )
236+ return fmt .Errorf ("%s: export %w" , name , err )
237237 }
238238 if ! s .IsDir () {
239- return fmt .Errorf ("%s: export %w" , c . Save , ErrIsFile )
239+ return fmt .Errorf ("%s: export %w" , name , ErrIsFile )
240240 }
241+ c .SaveName = name
241242 }
242243 return nil
243244}
@@ -288,7 +289,7 @@ func (c Config) separator(name string) string {
288289// Status summarizes the zip files scan.
289290func (c Config ) Status () string {
290291 if c .Log {
291- if c .Save != "" {
292+ if c .SaveName != "" {
292293 s := fmt .Sprintf ("Saved %d comments from %d finds" , c .saved , c .cmmts )
293294 c .WriteLog (s )
294295 }
@@ -314,7 +315,7 @@ func (c Config) Status() string {
314315 }
315316 s += color .Secondary .Sprint ("Scanned " ) +
316317 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 {
318319 s += color .Secondary .Sprint (", saved " ) +
319320 color .Primary .Sprintf ("%d text files" , c .saved )
320321 }
@@ -327,7 +328,7 @@ func (c Config) Status() string {
327328 return s
328329}
329330
330- // Save a zip cmmt to the file path.
331+ // SaveName a zip cmmt to the file path.
331332// Unless the overwrite argument is set, any previous cmmt text files are skipped.
332333func (c * Config ) save (dat save ) bool {
333334 // name, cmmt string, mod time.Time, ow bool
@@ -387,7 +388,7 @@ func valid(name string) bool {
387388// unique checks the destination path against an export map.
388389// The map contains a unique collection of previously used destination
389390// paths, to avoid creating duplicate text filenames while using the
390- // Save config.
391+ // SaveName config.
391392func (e export ) unique (zipPath , dest string ) string {
392393 base := filepath .Base (zipPath )
393394 name := strings .TrimSuffix (base , filepath .Ext (base )) + filename
0 commit comments