Skip to content

Commit

Permalink
add --install to update command
Browse files Browse the repository at this point in the history
  • Loading branch information
crhuber committed Jan 24, 2024
1 parent 55b5139 commit ec99815
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
28 changes: 22 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/urfave/cli/v2"
)

var version = "1.12.0"
var version = "1.12.1"

func main() {

Expand All @@ -37,7 +37,7 @@ func main() {
Commands: []*cli.Command{
{
Name: "add",
Usage: "add a new package to kelp config",
Usage: "add a new package to config",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "release",
Expand Down Expand Up @@ -113,7 +113,7 @@ func main() {
},
{
Name: "doctor",
Usage: "checks if kelp packages are installed properly",
Usage: "checks if packages are installed properly",
Action: func(cCtx *cli.Context) error {
// load config
kc, err := config.Load(cCtx.String("config"))
Expand Down Expand Up @@ -223,7 +223,7 @@ func main() {
{
Name: "remove",
Aliases: []string{"rm"},
Usage: "remove a packages from config and disk",
Usage: "remove a package from config and disk",
Action: func(cCtx *cli.Context) error {
project := cCtx.Args().First()
if project == "" {
Expand Down Expand Up @@ -256,7 +256,7 @@ func main() {
},
{
Name: "set",
Usage: "set package configuration in kelp config",
Usage: "set package configuration in config",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "release",
Expand Down Expand Up @@ -304,7 +304,15 @@ func main() {
},
{
Name: "update",
Usage: "update kelp packge",
Usage: "update kelp package in config",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "install",
Aliases: []string{"i"},
Value: false,
Usage: "also install package",
},
},
Action: func(cCtx *cli.Context) error {
project := cCtx.Args().First()
if project == "" {
Expand Down Expand Up @@ -356,6 +364,14 @@ func main() {
}
}

// auto install
if cCtx.Bool("install") {
err = install.Install(kp.Owner, kp.Repo, cCtx.String("release"))
if err != nil {
return err
}
}

return nil
},
},
Expand Down
7 changes: 6 additions & 1 deletion pkg/install/intstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,10 @@ func TestEvalAssetSuitability(t *testing.T) {
// pandoc-2.14.2-macOS.pkg
asset.BrowserDownloadURL = "https://github.com/foo/bar/releases/download/v1.0/pandoc-2.14.2-macOS.pkg"
require.Equal(t, 6, evaluateAssetSuitability(asset))

// gopass-1.15.11-darwin-amd64.tar.gz
asset.BrowserDownloadURL = "https://github.com/foo/bar/releases/download/v1.0/gopass-1.15.11-darwin-amd64.tar.gz"
require.Equal(t, 6, evaluateAssetSuitability(asset))
// gopass-1.15.11-darwin-arm64.tar.gz
asset.BrowserDownloadURL = "https://github.com/foo/bar/releases/download/v1.0/gopass-1.15.11-darwin-arm64.tar.gz"
require.Equal(t, 9, evaluateAssetSuitability(asset))
}
2 changes: 2 additions & 0 deletions pkg/types/github.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
"fmt"
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -96,6 +97,7 @@ func (a Asset) IsMacAsset() bool {
}

func (a Asset) IsSameArchitecture() bool {
fmt.Println(runtime.GOARCH)
if strings.Contains(strings.ToLower(a.BrowserDownloadURL), strings.ToLower(runtime.GOARCH)) {
return true
} else if runtime.GOARCH == "amd64" && strings.Contains(strings.ToLower(a.BrowserDownloadURL), "x86_64") {
Expand Down

0 comments on commit ec99815

Please sign in to comment.