diff --git a/README.md b/README.md index 5d91464..362dc1c 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/installer.ps1 b/installer.ps1 index 985a16b..9e788af 100755 --- a/installer.ps1 +++ b/installer.ps1 @@ -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" diff --git a/installer.sh b/installer.sh index 99dc7a6..76b75f3 100755 --- a/installer.sh +++ b/installer.sh @@ -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 ;; *) @@ -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 diff --git a/cli.go b/new.go similarity index 100% rename from cli.go rename to new.go diff --git a/root.go b/root.go index 7d24e46..9a2026d 100644 --- a/root.go +++ b/root.go @@ -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. @@ -34,6 +34,7 @@ func Execute() error { genCmd.AddCommand(formCmd) AddCmd(newCmd) + AddCmd(runCmd) AddCmd(genCmd) return rootCmd.Execute() diff --git a/run.go b/run.go new file mode 100644 index 0000000..250aa6b --- /dev/null +++ b/run.go @@ -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) +}