-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a deps.dev command to get repository information
- Loading branch information
Showing
6 changed files
with
72 additions
and
0 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,28 @@ | ||
package deps | ||
|
||
import ( | ||
"fmt" | ||
"encoding/json" | ||
|
||
"github.com/snyk/parlay/lib/deps" | ||
|
||
"github.com/rs/zerolog" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewRepoCommand(logger zerolog.Logger) *cobra.Command { | ||
cmd := cobra.Command{ | ||
Use: "repo <repo>", | ||
Short: "Return repo info from deps.dev", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
proj, err := deps.GetRepoData(args[0]) | ||
if err != nil { | ||
logger.Fatal().Err(err).Msg("An error occured") | ||
} | ||
b, err := json.Marshal(proj) | ||
fmt.Print(string(b)) | ||
}, | ||
} | ||
return &cmd | ||
} |
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 deps | ||
|
||
import ( | ||
"github.com/rs/zerolog" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewDepsRootCommand(logger zerolog.Logger) *cobra.Command { | ||
cmd := cobra.Command{ | ||
Use: "deps", | ||
Short: "Commands for using parlay with deps.dev", | ||
Aliases: []string{"d"}, | ||
DisableFlagsInUseLine: true, | ||
SilenceUsage: true, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
_ = cmd.Help() | ||
}, | ||
} | ||
|
||
cmd.AddCommand(NewRepoCommand(logger)) | ||
|
||
return &cmd | ||
} |
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,13 @@ | ||
package deps | ||
|
||
import ( | ||
"github.com/edoardottt/depsdev/pkg/depsdev" | ||
) | ||
|
||
func GetRepoData(url string) (*depsdev.Project, error) { | ||
proj, err := depsdev.GetProject(url) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &proj, nil | ||
} |