From 612beced6f249a67d78538288a610d09c8932ebf Mon Sep 17 00:00:00 2001 From: Marwan Hawari <59078997+marwanhawari@users.noreply.github.com> Date: Tue, 2 Apr 2024 04:32:53 +0100 Subject: [PATCH] remove list --assets flag (#34) --- cmd/list.go | 8 +++----- lib/stewfile.go | 2 +- lib/stewfile_test.go | 4 ++-- lib/util.go | 9 ++------- lib/util_test.go | 14 -------------- main.go | 6 +----- 6 files changed, 9 insertions(+), 34 deletions(-) diff --git a/cmd/list.go b/cmd/list.go index 5f22632..5daa35c 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -7,7 +7,7 @@ import ( ) // List is executed when you run `stew list` -func List(cliTagsFlag bool, cliAssetsFlag bool) { +func List(cliTagsFlag bool) { userOS, userArch, _, systemInfo, err := stew.Initialize() stew.CatchAndExit(err) @@ -26,12 +26,10 @@ func List(cliTagsFlag bool, cliAssetsFlag bool) { case "other": fmt.Println(pkg.URL) case "github": - if !cliTagsFlag && !cliAssetsFlag { - fmt.Println(pkg.Owner + "/" + pkg.Repo) - } else if cliTagsFlag && !cliAssetsFlag { + if cliTagsFlag { fmt.Println(pkg.Owner + "/" + pkg.Repo + "@" + pkg.Tag) } else { - fmt.Println(pkg.Owner + "/" + pkg.Repo + "@" + pkg.Tag + "::" + pkg.Asset) + fmt.Println(pkg.Owner + "/" + pkg.Repo) } } } diff --git a/lib/stewfile.go b/lib/stewfile.go index ded1820..1f54f2f 100644 --- a/lib/stewfile.go +++ b/lib/stewfile.go @@ -111,7 +111,7 @@ func ReadStewLockFileContents(lockFilePath string) ([]string, error) { case "other": packages = append(packages, pkg.URL) case "github": - path := fmt.Sprintf("%s/%s@%s::%s", pkg.Owner, pkg.Repo, pkg.Tag, pkg.Asset) + path := fmt.Sprintf("%s/%s@%s", pkg.Owner, pkg.Repo, pkg.Tag) packages = append(packages, path) } } diff --git a/lib/stewfile_test.go b/lib/stewfile_test.go index 74a4353..26af20a 100644 --- a/lib/stewfile_test.go +++ b/lib/stewfile_test.go @@ -89,8 +89,8 @@ var testStewLockFileContents string = `{ ` var testStewLockFileSlice []string = []string{ - "cli/cli@v2.4.0::gh_2.4.0_macOS_amd64.tar.gz", - "junegunn/fzf@0.29.0::fzf-0.29.0-darwin_arm64.zip", + "cli/cli@v2.4.0", + "junegunn/fzf@0.29.0", "https://github.com/sharkdp/hyperfine/releases/download/v1.12.0/hyperfine-v1.12.0-x86_64-apple-darwin.tar.gz", } diff --git a/lib/util.go b/lib/util.go index 5cd96d3..f8b02ed 100644 --- a/lib/util.go +++ b/lib/util.go @@ -235,7 +235,7 @@ func ParseCLIInput(cliInput string) (CLIInput, error) { func parseGithubInput(cliInput string) (CLIInput, error) { parsedInput := CLIInput{} parsedInput.IsGithubInput = true - trimmedString := strings.Trim(strings.Trim(strings.Trim(strings.TrimSpace(cliInput), "/"), "@"), "::") + trimmedString := strings.Trim(strings.Trim(strings.TrimSpace(cliInput), "/"), "@") splitInput := strings.SplitN(trimmedString, "@", 2) ownerAndRepo := splitInput[0] @@ -244,12 +244,7 @@ func parseGithubInput(cliInput string) (CLIInput, error) { parsedInput.Repo = splitOwnerAndRepo[1] if len(splitInput) == 2 { - tagAndAsset := splitInput[1] - splitTagAndAsset := strings.SplitN(tagAndAsset, "::", 2) - parsedInput.Tag = splitTagAndAsset[0] - if len(splitTagAndAsset) == 2 { - parsedInput.Asset = splitTagAndAsset[1] - } + parsedInput.Tag = splitInput[1] } return parsedInput, nil diff --git a/lib/util_test.go b/lib/util_test.go index 1434abb..892fbb8 100644 --- a/lib/util_test.go +++ b/lib/util_test.go @@ -505,20 +505,6 @@ func Test_parseGithubInput(t *testing.T) { }, wantErr: false, }, - { - name: "test3", - args: args{ - cliInput: "marwanhawari/ppath@v0.0.3::ppath-v0.0.3-linux-amd64.tar.gz", - }, - want: CLIInput{ - IsGithubInput: true, - Owner: "marwanhawari", - Repo: "ppath", - Tag: "v0.0.3", - Asset: "ppath-v0.0.3-linux-amd64.tar.gz", - }, - wantErr: false, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/main.go b/main.go index ba11c7c..e1b2e71 100644 --- a/main.go +++ b/main.go @@ -89,13 +89,9 @@ func main() { Name: "tags", Usage: "include the version tags", }, - &cli.BoolFlag{ - Name: "assets", - Usage: "include the assets and version tags", - }, }, Action: func(c *cli.Context) error { - cmd.List(c.Bool("tags"), c.Bool("assets")) + cmd.List(c.Bool("tags")) return nil }, },