forked from varia/go-sh-manymanuals
show folder icons next to folders
This commit is contained in:
parent
dbb59b19b6
commit
6c37ddb1fd
@ -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…
Reference in New Issue
Block a user