Browse Source

show folder icons next to folders

main
crunk 2 years ago
parent
commit
6c37ddb1fd
  1. 16
      go-sh-manymanuals.go

16
go-sh-manymanuals.go

@ -36,10 +36,9 @@ type model struct {
}
func initialModel() model {
viper.SetConfigFile("config.json")
viper.ReadInConfig()
folder := viper.Get("ManualDir").(string)
manuals, err := gatherManuals(folder)
if err != nil {
log.Fatalf("unable to read manuals: %s", err)
os.Exit(1)
@ -50,15 +49,19 @@ func initialModel() model {
}
}
func gatherManuals(folder string) ([]string, error) {
fileInfos, err := ioutil.ReadDir(fmt.Sprintf("./%s", folder))
func gatherManuals(directory string) ([]string, error) {
fileInfos, err := ioutil.ReadDir(fmt.Sprintf("./%s", directory))
if err != nil {
return nil, err
}
var filenames []string
for _, fileInfo := range fileInfos {
filenames = append(filenames, fileInfo.Name())
filename := fileInfo.Name()
if fileInfo.IsDir() {
filename = fmt.Sprintf("📁 %s", fileInfo.Name())
}
filenames = append(filenames, filename)
}
return filenames, nil
@ -113,6 +116,9 @@ func main() {
os.Exit(0)
}
viper.SetConfigFile("config.json")
viper.ReadInConfig()
p := tea.NewProgram(initialModel(), tea.WithAltScreen())
if err := p.Start(); err != nil {
fmt.Printf("Alas, there's been an error: %v", err)

Loading…
Cancel
Save