More correctly use build constraints in entryList.go

This commit is contained in:
2024-03-06 20:45:02 -05:00
parent 11644b37ff
commit 14b3d7bd45
5 changed files with 32 additions and 20 deletions
+2 -10
View File
@@ -161,11 +161,7 @@ func EntryListGen() {
containsFiles = true
skippedDirList[i] = false // the directory header is being printed, indicate that it is not being skipped
indent, vanityDirectory = indentSubtractor(skippedDirList, dirList, i, indent) // calculate the final indentation multiplier
if !offline.Windows { // for consistency, format directories with UNIX-style path separators on all platforms
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+offline.AnsiReset+"\n", vanityDirectory)
} else {
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+offline.AnsiReset+"\n", strings.ReplaceAll(vanityDirectory, offline.PathSeparator, "/"))
}
printDirectoryHeader(vanityDirectory, indent)
}
charCounter, colorAlternator = printFileEntry(file, lastSlash, charCounter, colorAlternator, indent)
@@ -177,11 +173,7 @@ func EntryListGen() {
if dirListLength > 1 { // and directories besides the root-level exist... display directory header and empty directory warning
skippedDirList[i] = false // the directory header is being printed, indicate that it is not being skipped
indent, vanityDirectory = indentSubtractor(skippedDirList, dirList, i, indent) // calculate the final indentation multiplier
if !offline.Windows { // for consistency, format directories with UNIX-style path separators on all platforms
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+offline.AnsiReset+"\n", vanityDirectory)
} else {
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+offline.AnsiReset+"\n", strings.ReplaceAll(vanityDirectory, offline.PathSeparator, "/"))
}
printDirectoryHeader(vanityDirectory, indent)
fmt.Print(strings.Repeat(" ", indent*2) + ansiEmptyDirectoryWarning + "-empty directory-" + offline.AnsiReset)
} else { // warn if the only thing that exists is the root-level directory
fmt.Print("\n\nNothing's here! For help creating your first entry, run \"mutn help\".")
+13
View File
@@ -0,0 +1,13 @@
//go:build !windows
package cli
import (
"fmt"
"github.com/rwinkhart/MUTN/src/offline"
"strings"
)
func printDirectoryHeader(vanityDirectory string, indent int) {
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+offline.AnsiReset+"\n", vanityDirectory)
}
+13
View File
@@ -0,0 +1,13 @@
//go:build windows
package cli
import (
"fmt"
"github.com/rwinkhart/MUTN/src/offline"
"strings"
)
func printDirectoryHeader(vanityDirectory string, indent int) {
fmt.Printf("\n\n"+strings.Repeat(" ", indent*2)+ansiDirectoryHeader+"%s/"+offline.AnsiReset+"\n", strings.ReplaceAll(vanityDirectory, offline.PathSeparator, "/"))
}
+2 -5
View File
@@ -5,8 +5,5 @@ package offline
// EntryRoot path to libmutton entry directory
var EntryRoot = home + "/.local/share/libmutton"
// exported constants
const (
PathSeparator = "/"
Windows = false
)
// PathSeparator defines the character used to separate directories in a path (platform-specific)
const PathSeparator = "/"
+2 -5
View File
@@ -5,8 +5,5 @@ package offline
// EntryRoot path to libmutton entry directory
var EntryRoot = home + "\\AppData\\Local\\libmutton\\entries"
// exported constants
const (
PathSeparator = "\\"
Windows = true
)
// PathSeparator defines the character used to separate directories in a path (platform-specific)
const PathSeparator = "\\"