-
-
Notifications
You must be signed in to change notification settings - Fork 2
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 (#13)
- feat: add version and update command - docs: Update new command in README - chore: Update CliVersion variable in the `cmd/version.go` file - ci: Enable create-summary option in releases workflow
- Loading branch information
1 parent
76d6a11
commit c5c314b
Showing
5 changed files
with
62 additions
and
1 deletion.
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 gencli to the latest version", | ||
Long: `This command will help you to update gencli to the latest version.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
update() | ||
}, | ||
} | ||
|
||
func update() { | ||
cmd := exec.Command("go", "install", "github.com/Pradumnasaraf/gencli@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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
const CliVersion = "v1.4.0" | ||
|
||
// versionCmd represents the version command | ||
var versionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "Know the installed version of gencli", | ||
Long: `This command will help you to know the installed version of gencli`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("gencli version:", CliVersion) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(versionCmd) | ||
} |