Skip to content

Commit

Permalink
Merge branch 'release/v0.1.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmaymishu committed Nov 20, 2024
2 parents db2613d + 2128c2b commit 3682873
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Lemmego CLI is used for generating the framework components.
### For Linux & macOS Users

```sh
curl -fsSL https://raw.githubusercontent.com/lemmego/cli/refs/tags/v0.1.8/installer.sh | sudo sh
curl -fsSL https://raw.githubusercontent.com/lemmego/cli/refs/tags/v0.1.9/installer.sh | sudo sh
```


Expand Down
4 changes: 2 additions & 2 deletions installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ function Install-Lemmego {

if ($arch -match "64-bit") {
if ($env:PROCESSOR_ARCHITEW6432 -eq "ARM64") {
$downloadUrl = "https://github.com/lemmego/cli/releases/download/v0.1.8/lemmego-v0.1.8-windows-arm64.exe"
$downloadUrl = "https://github.com/lemmego/cli/releases/download/v0.1.9/lemmego-v0.1.9-windows-arm64.exe"
} else {
$downloadUrl = "https://github.com/lemmego/cli/releases/download/v0.1.8/lemmego-v0.1.8-windows-amd64.exe"
$downloadUrl = "https://github.com/lemmego/cli/releases/download/v0.1.9/lemmego-v0.1.9-windows-amd64.exe"
}
} else {
Write-Host "Unsupported architecture: $arch"
Expand Down
8 changes: 4 additions & 4 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ download_binary() {
case $OS in
darwin|linux)
if [ "$ARCH" = "amd64" ]; then
download_url="https://github.com/lemmego/cli/releases/download/v0.1.8/lemmego-v0.1.8-$OS-amd64"
download_url="https://github.com/lemmego/cli/releases/download/v0.1.9/lemmego-v0.1.9-$OS-amd64"
elif [ "$ARCH" = "arm64" ]; then
download_url="https://github.com/lemmego/cli/releases/download/v0.1.8/lemmego-v0.1.8-$OS-arm64"
download_url="https://github.com/lemmego/cli/releases/download/v0.1.9/lemmego-v0.1.9-$OS-arm64"
fi
;;
*)
Expand All @@ -27,14 +27,14 @@ download_binary() {
fi

echo "Downloading: $download_url"
curl -L "$download_url" -o "lemmego-v0.1.8-$OS-$ARCH"
curl -L "$download_url" -o "lemmego-v0.1.9-$OS-$ARCH"
if [ $? -ne 0 ]; then
echo "Download failed. Please check if you have enough disk space or permissions."
exit 1
fi

echo "Moving file to /usr/local/bin"
sudo mv "lemmego-v0.1.8-$OS-$ARCH" /usr/local/bin/lemmego
sudo mv "lemmego-v0.1.9-$OS-$ARCH" /usr/local/bin/lemmego
if [ $? -ne 0 ]; then
echo "Failed to move file. You might need to run this script with sudo or check permissions."
exit 1
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var shouldRunInteractively = false
var rootCmd = &cobra.Command{
Use: "",
Short: fmt.Sprintf("%s", os.Getenv("APP_NAME")),
Version: "0.1.8",
Version: "0.1.9",
}

// AddCmd adds a new sub-command to the root command.
Expand All @@ -34,6 +34,7 @@ func Execute() error {
genCmd.AddCommand(formCmd)

AddCmd(newCmd)
AddCmd(runCmd)
AddCmd(genCmd)

return rootCmd.Execute()
Expand Down
48 changes: 48 additions & 0 deletions run.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package cli

import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/spf13/cobra"
)

const lemmegoIndicator = "github.com/lemmego/api/app"

var runCmd = &cobra.Command{
Use: "run [args]",
Short: "Run the Lemmego application with optional arguments",
Run: func(cmd *cobra.Command, args []string) {
// Check if we're in a Lemmego project
if !isLemmegoProject() {
fmt.Println("Error: This does not appear to be a Lemmego project directory.")
return
}

// Construct the go run command
goRunCmd := exec.Command("go", append([]string{"run", "./cmd/app"}, args...)...)

// Set up stdout and stderr to be the same as the parent's
goRunCmd.Stdout = os.Stdout
goRunCmd.Stderr = os.Stderr

// Execute the command
if err := goRunCmd.Run(); err != nil {
fmt.Printf("Error running the app: %v\n", err)
return
}
},
}

// Function to check if the current directory is a Lemmego project
func isLemmegoProject() bool {
mainGoPath := filepath.Join("./cmd/app", "main.go")
content, err := os.ReadFile(mainGoPath)
if err != nil {
return false
}
return strings.Contains(string(content), lemmegoIndicator)
}

0 comments on commit 3682873

Please sign in to comment.