-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add version and update command (#28)
* feat: add version and update command * docs: Update PULL_REQUEST_TEMPLATE.md
- Loading branch information
1 parent
c0f24c8
commit 1b72d0c
Showing
5 changed files
with
47 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters