diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 299264d..0a4b378 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,16 +1,12 @@ - - -## 🛠️ Fixes Issue - - +### 🛠️ Fixes Issue -## 👨‍💻 Changes proposed +### 👨‍💻 Changes proposed -## ✔️ Check List (Check all the applicable boxes) +### ✔️ Check List (Check all the applicable boxes) - -## 📷 Screenshots +### 📷 Screenshots diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 23e1442..10906a3 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -19,7 +19,7 @@ jobs: github-token: ${{ secrets.PA_TOKEN }} output-file: "false" skip-commit: "true" - + create-summary: 'true' outputs: tag: ${{ steps.changelog.outputs.tag }} diff --git a/cmd/root.go b/cmd/root.go index 78b77fc..174e9b5 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -13,6 +13,7 @@ import ( var rootCmd = &cobra.Command{ Use: "candy [command]", Short: "Do all your tedious tasks with a single command", + Run: func(cmd *cobra.Command, args []string) { err := cmd.Help() checkNilErr(err) diff --git a/cmd/update.go b/cmd/update.go new file mode 100644 index 0000000..af49ae4 --- /dev/null +++ b/cmd/update.go @@ -0,0 +1,34 @@ +package cmd + +import ( + "fmt" + "os/exec" + + "github.com/spf13/cobra" +) + +// updateCmd represents the update command +var updateCmd = &cobra.Command{ + Use: "update", + Short: "Update candy to the latest version", + Long: `This command will help you to update candy to the latest version.`, + Run: func(cmd *cobra.Command, args []string) { + update() + }, +} + +func update() { + cmd := exec.Command("go", "install", "github.com/Pradumnasaraf/candy@latest") + _, err := cmd.Output() + + if err != nil { + fmt.Println("Error executing command:", err) + return + } + + fmt.Printf("CLI updated successfully to the latest version (If any). Current version is: %s\n", CliVersion) +} + +func init() { + rootCmd.AddCommand(updateCmd) +} diff --git a/cmd/version.go b/cmd/version.go index 32e4e59..9d47d11 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -4,59 +4,16 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/tcnksm/go-latest" ) -var ( - checkLatest bool -) - -const ( - CLI_VERSION = "1.7.0" - OWNER = "Pradumnasaraf" - REPO = "candy" -) +const CliVersion = "v1.8.0" // versionCmd represents the version command var versionCmd = &cobra.Command{ Use: "version", - Short: "outputs the cli version", + Short: "Know the installed version of candy", + Long: `This command will help you to know the installed version of candy`, Run: func(cmd *cobra.Command, args []string) { - - if checkLatest { - checkForNewVersion() - } else { - fmt.Println(CLI_VERSION) - } - + fmt.Println("candy version:", CliVersion) }, } - -func checkForNewVersion() { - - githubTag := &latest.GithubTag{ - Owner: OWNER, - Repository: REPO, - FixVersionStrFunc: latest.DeleteFrontV(), - } - - res, err := latest.Check(githubTag, CLI_VERSION) - - if err != nil { - fmt.Println("Unable to check for latest version. Check your internet connection") - return - } - - if res.Outdated { - fmt.Printf("The latest version of candy is %s.\nPlease update to the latest version by running go get -u github.com/Pradumnasaraf/candy@latest", res.Current) - return - } - - fmt.Println("You are using the latest version of candy") - -} - -func init() { - // Flags for the version command - versionCmd.Flags().BoolVarP(&checkLatest, "latest", "l", false, "Check if the latest version is installed") -}