Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/mxcli/cmd_tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Example:

m := tui.NewApp(mxcliPath, projectPath)
p := tea.NewProgram(m, tea.WithAltScreen(), tea.WithMouseCellMotion())
m.StartWatcher(p)
if _, err := p.Run(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/mxcli/docker/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func Build(opts BuildOptions) error {
// Step 4: Pre-build check
if !opts.SkipCheck {
fmt.Fprintln(w, "Checking project for errors...")
mxPath, err := resolveMx(opts.MxBuildPath)
mxPath, err := ResolveMx(opts.MxBuildPath)
if err != nil {
fmt.Fprintf(w, " Skipping check: %v\n", err)
} else {
Expand Down
17 changes: 14 additions & 3 deletions cmd/mxcli/docker/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func Check(opts CheckOptions) error {
}

// Resolve mx binary
mxPath, err := resolveMx(opts.MxBuildPath)
mxPath, err := ResolveMx(opts.MxBuildPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -67,9 +67,9 @@ func mxBinaryName() string {
return "mx"
}

// resolveMx finds the mx executable.
// ResolveMx finds the mx executable.
// Priority: derive from mxbuild path > PATH lookup.
func resolveMx(mxbuildPath string) (string, error) {
func ResolveMx(mxbuildPath string) (string, error) {
if mxbuildPath != "" {
// Resolve mxbuild first to handle directory paths
resolvedMxBuild, err := resolveMxBuild(mxbuildPath)
Expand Down Expand Up @@ -102,5 +102,16 @@ func resolveMx(mxbuildPath string) (string, error) {
return p, nil
}

// Try cached mxbuild installations (~/.mxcli/mxbuild/*/modeler/mx).
// NOTE: lexicographic sort is imperfect for versions (e.g. "9.x" > "10.x"),
// but this is a fallback-of-last-resort — in practice users typically have
// only one mxbuild version installed.
if home, err := os.UserHomeDir(); err == nil {
matches, _ := filepath.Glob(filepath.Join(home, ".mxcli", "mxbuild", "*", "modeler", mxBinaryName()))
if len(matches) > 0 {
return matches[len(matches)-1], nil
}
}

return "", fmt.Errorf("mx not found; specify --mxbuild-path pointing to Mendix installation directory")
}
Loading
Loading