Skip to content

Commit

Permalink
named constants for overwrite mode
Browse files Browse the repository at this point in the history
  • Loading branch information
scrouthtv committed May 1, 2021
1 parent fe990ce commit 0585c58
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ qwertz
*.img
test
test2
old.txt
new.txt

# executables:
a.out
Expand Down
33 changes: 20 additions & 13 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ const (
VerbDebug
)

// onExistingFile takes one of these values:
// 0 skip
// 1 overwrite
// 2 ask.
var onExistingFile uint8 = 2
var onExistingFile uint8 = Ask

const (
// Skip existing files.
Skip uint8 = iota

// Overwrite existing files.
Overwrite

// Ask the user on existing files.
Ask
)

// followSymlinks takes one of these values:
// 0 ignore symlinks
Expand Down Expand Up @@ -64,11 +71,11 @@ func parseKeyValue(key string, value string) {
case "overwrite":
switch value {
case "skip":
onExistingFile = 0
onExistingFile = Skip
case "overwrite":
onExistingFile = 1
onExistingFile = Overwrite
case "ask":
onExistingFile = 2
onExistingFile = Ask
}
case "symlinks":
switch value {
Expand Down Expand Up @@ -154,18 +161,18 @@ func parseFlag(prefix string, flag string) {
case "colortest":
printColortest()
os.Exit(0)
case "f", "force":
onExistingFile = 1
case "n", "no-clobber", "no-overwrite":
onExistingFile = Skip
case "f", "force", "overwrite":
onExistingFile = Overwrite
case "i", "interactive":
onExistingFile = 2
onExistingFile = Ask
case "no-config":
doReadConfig = false
case "color":
color.Init(true)
case "reflink":
doReflinks = 2
case "n", "no-clobber": // case "no-overwrite":
onExistingFile = 0
default:
errUnknownOption(prefix + flag)
}
Expand Down
2 changes: 1 addition & 1 deletion ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func printColortest() {
}

func verbVerboseEnabled() {
fmt.Print(color.FGColors.Yellow + "Verbose mode enabled." + color.Text.Reset)
fmt.Println(color.FGColors.Yellow + "Verbose mode enabled." + color.Text.Reset)
}

func verbFlags() {
Expand Down

0 comments on commit 0585c58

Please sign in to comment.