Skip to content

Commit

Permalink
remove list --assets flag (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanhawari authored Apr 2, 2024
1 parent 0a27356 commit 612bece
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 34 deletions.
8 changes: 3 additions & 5 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/stewfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/stewfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ var testStewLockFileContents string = `{
`

var testStewLockFileSlice []string = []string{
"cli/[email protected]::gh_2.4.0_macOS_amd64.tar.gz",
"junegunn/[email protected]::fzf-0.29.0-darwin_arm64.zip",
"cli/[email protected]",
"junegunn/[email protected]",
"https://github.com/sharkdp/hyperfine/releases/download/v1.12.0/hyperfine-v1.12.0-x86_64-apple-darwin.tar.gz",
}

Expand Down
9 changes: 2 additions & 7 deletions lib/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
14 changes: 0 additions & 14 deletions lib/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,20 +505,6 @@ func Test_parseGithubInput(t *testing.T) {
},
wantErr: false,
},
{
name: "test3",
args: args{
cliInput: "marwanhawari/[email protected]::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) {
Expand Down
6 changes: 1 addition & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
Expand Down

0 comments on commit 612bece

Please sign in to comment.