Skip to content

Commit 5e7f15d

Browse files
committed
fix errors, replace screenshot
1 parent 7fe9b05 commit 5e7f15d

File tree

5 files changed

+36
-25
lines changed

5 files changed

+36
-25
lines changed

func-main.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@ func CloneMecchi() LoaderResult[string] {
2121

2222
fullPath := filepath.Join(currentDir, MecchiFolder)
2323

24-
_, err := git.PlainClone(fullPath, false, &git.CloneOptions{
24+
git.PlainClone(fullPath, false, &git.CloneOptions{
2525
URL: MecchiRepo,
2626
})
2727

28-
if err != nil {
29-
return LoaderResult[string]{success: false, error: err.Error()}
30-
}
31-
3228
return LoaderResult[string]{success: true, result: fullPath}
3329
}
3430

images/mecchi-loader.png

-858 Bytes
Loading

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func MainUi(input *widget.Entry, loading func(bool)) *fyne.Container {
5757
mecchiFolder := MecchiFolderExists()
5858

5959
if !mecchiFolder.success {
60-
OutputResult(input, "Mecchi does not exist, install it first!")
60+
OutputResult(input, "Mecchi does not exist, install it first! "+mecchiFolder.error)
6161
} else {
6262
OutputResult(input, "Launching Mecchi...")
6363
mecchiProcess := LaunchMecchi(mecchiFolder.result, input)

mecchi-loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
func main() {
1212
mecchiLoader := app.New()
1313

14-
window := mecchiLoader.NewWindow("mecchi loader")
14+
window := mecchiLoader.NewWindow("Mecchi Loader")
1515
window.Resize(fyne.NewSize(WindowWidth, WindowHeight))
1616

1717
input := widget.NewMultiLineEntry()

utils.go

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func MecchiFolderExists() LoaderResult[string] {
5555
return LoaderResult[string]{success: false, error: err.Error()}
5656
}
5757

58-
subdirectory, err := FindFile(currentDir, "src", "mecchi.py")
58+
subdirectory, err := FindMecchiDirectory(currentDir)
5959

6060
if err != nil {
6161
return LoaderResult[string]{success: false, error: err.Error()}
@@ -64,34 +64,49 @@ func MecchiFolderExists() LoaderResult[string] {
6464
if subdirectory != "" {
6565
return LoaderResult[string]{success: true, result: subdirectory}
6666
} else {
67-
return LoaderResult[string]{success: false, error: "mecchi folder not found"}
67+
return LoaderResult[string]{success: false, error: currentDir}
6868
}
6969
}
7070

71-
func FindFile(rootPath string, foldername string, filename string) (string, error) {
72-
var resultPath string
71+
func containsFile(folderPath string, targetFile string) bool {
72+
filePath := filepath.Join(folderPath, targetFile)
73+
_, err := os.Stat(filePath)
74+
return err == nil
75+
}
7376

74-
err := filepath.WalkDir(rootPath, func(path string, d os.DirEntry, err error) error {
75-
if err != nil {
76-
return err
77-
}
77+
func FindMecchiDirectory(rootPath string) (string, error) {
78+
targetFolder := "src"
79+
targetFile := "mecchi.py"
7880

79-
if d.IsDir() && d.Name() == foldername {
80-
targetFilePath := filepath.Join(path, filename)
81-
if _, err := os.Stat(targetFilePath); err == nil {
82-
resultPath = filepath.Dir(path)
83-
return filepath.SkipDir
84-
}
85-
}
81+
folders, err := os.ReadDir(rootPath)
8682

87-
return nil
88-
})
83+
for _, folder := range folders {
84+
if folder.IsDir() {
85+
fmt.Println(folder.Name())
86+
}
87+
}
8988

9089
if err != nil {
90+
fmt.Printf(err.Error())
9191
return "", err
9292
}
9393

94-
return resultPath, nil
94+
for _, folder := range folders {
95+
if folder.IsDir() {
96+
subfolderPath := filepath.Join(rootPath, folder.Name())
97+
srcFilePath := filepath.Join(subfolderPath, targetFolder, targetFile)
98+
fmt.Println(srcFilePath)
99+
100+
_, err := os.Stat(srcFilePath)
101+
if err == nil {
102+
fmt.Println("found " + subfolderPath)
103+
return subfolderPath, nil
104+
}
105+
106+
}
107+
}
108+
109+
return "", nil
95110
}
96111

97112
func OpenInBrowser(url string) error {

0 commit comments

Comments
 (0)