Skip to content

Commit

Permalink
fix: add version command properly
Browse files Browse the repository at this point in the history
  • Loading branch information
furan917 committed Nov 24, 2023
1 parent fff5962 commit db3df42
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
token: ${{ secrets.PAT_TOKEN }}
release-type: go
package-name: "MageComm"
extra-files: |
version.txt
- name: Log release info
run: |
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ config file can be in yaml or json format e.g `config.yml` or `config.json`, ple

Download the latest release from the [releases page](https://github.com/furan917/magecomm/releases) for your platform and extract to a directory in your PATH.

Then check your installed version with `magecomm version`

example config.yml:
```
disallow_configfile_overwrite: true
Expand Down
14 changes: 12 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package main

import (
_ "embed"
"fmt"
"github.com/spf13/cobra"
"magecomm/cmd"
"magecomm/config_manager"
"magecomm/logger"
"magecomm/notifictions"
"magecomm/services"
"os"
"strings"
)

//go:embed version.txt
var version string

var RootCmd = &cobra.Command{
Use: "magecomm",
Short: "MageComm CLI is a command line tool for managing Magento applications",
PersistentPreRun: func(cmd *cobra.Command, args []string) {

debug, _ := cmd.Flags().GetBool("debug")
if debug {
logger.EnableDebugMode()
Expand All @@ -33,11 +38,16 @@ func initializeModuleWhichRequireConfig() {
}

func main() {
if len(os.Args) > 1 && os.Args[1] == "version" {
fmt.Printf("Magecomm Version: %s\n", strings.TrimSpace(version))
return
}

RootCmd.AddCommand(cmd.ListenCmd)
RootCmd.AddCommand(cmd.MagerunCmd)
//RootCmd.AddCommand(cmd.DeployCmd)
RootCmd.AddCommand(cmd.CatCmd)
//RootCmd.AddCommand(cmd.CatDeployCmd)
//RootCmd.AddCommand(cmd.DeployCmd)

RootCmd.PersistentFlags().String("config", "", "Path to config file")
RootCmd.PersistentFlags().Bool("debug", false, "Enable debug mode")
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.1.10

0 comments on commit db3df42

Please sign in to comment.