mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-06 00:57:15 -04:00
Fix empty directory warning appearing for root if no subdirectories are present (but files are)
This commit is contained in:
+8
-5
@@ -43,7 +43,7 @@ func printFileEntry(entry string, lastSlash int, charCounter int, colorAlternato
|
|||||||
|
|
||||||
// EntryListGen generates and displays full entry list
|
// EntryListGen generates and displays full entry list
|
||||||
func EntryListGen() {
|
func EntryListGen() {
|
||||||
fmt.Print("\nfor a list of usable commands, run \"mutn help\"\n\n\033[38;5;0;48;5;15mlibmutton entries:\033[0m")
|
fmt.Print("\n\u001B[38;5;0;48;5;15mlibmutton entries:\u001B[0m")
|
||||||
|
|
||||||
// walk entry directory
|
// walk entry directory
|
||||||
_ = filepath.WalkDir(EntryRoot,
|
_ = filepath.WalkDir(EntryRoot,
|
||||||
@@ -83,7 +83,8 @@ func EntryListGen() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DirListMain iteration
|
dirListMainLength := len(dirListMain) // save length for multiple references below
|
||||||
|
if dirListMainLength > 1 { // DirListMain iteration - only run if non-root-level directories are present
|
||||||
nextStartIndex := 0 // set to track where to resume when iterating through fileListMain
|
nextStartIndex := 0 // set to track where to resume when iterating through fileListMain
|
||||||
var containsSubdirectory bool // set to track whether the current directory contains a subdirectory - if it does, empty directory warnings will not be printed
|
var containsSubdirectory bool // set to track whether the current directory contains a subdirectory - if it does, empty directory warnings will not be printed
|
||||||
for i, directory := range dirListMain {
|
for i, directory := range dirListMain {
|
||||||
@@ -93,7 +94,7 @@ func EntryListGen() {
|
|||||||
colorAlternator = 1
|
colorAlternator = 1
|
||||||
|
|
||||||
// check if next directory is within the current one
|
// check if next directory is within the current one
|
||||||
if len(dirListMain) > i+1 {
|
if dirListMainLength > i+1 {
|
||||||
nextDir := dirListMain[i+1]
|
nextDir := dirListMain[i+1]
|
||||||
if directory == nextDir[:strings.LastIndex(nextDir, PathSeparator)] {
|
if directory == nextDir[:strings.LastIndex(nextDir, PathSeparator)] {
|
||||||
containsSubdirectory = true
|
containsSubdirectory = true
|
||||||
@@ -142,9 +143,11 @@ func EntryListGen() {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Printf("\n\n\033[38;5;7;48;5;8m%s/\033[0m\n", strings.ReplaceAll(directory, PathSeparator, "/"))
|
fmt.Printf("\n\n\033[38;5;7;48;5;8m%s/\033[0m\n", strings.ReplaceAll(directory, PathSeparator, "/"))
|
||||||
}
|
}
|
||||||
fmt.Print("\033[38;5;9m-empty directory-\033[0m")
|
fmt.Print("\033[38;5;9m-Empty Directory-\033[0m")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else if !ran {
|
||||||
|
fmt.Print("\n\nNothing's here! For help creating your first entry, run \"mutn help\".")
|
||||||
}
|
}
|
||||||
|
|
||||||
// print trailing new lines for proper spacing after entry list is complete
|
// print trailing new lines for proper spacing after entry list is complete
|
||||||
|
|||||||
Reference in New Issue
Block a user