Skip to content

Commit

Permalink
feat: add kcl mod git dependency examples
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Jan 15, 2024
1 parent 2c57135 commit 7987b84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/kcl/commands/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
update bool
git string
tag string
commit string
target string
)

Expand Down
12 changes: 8 additions & 4 deletions cmd/kcl/commands/mod_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const (
# Add the module dependency named "k8s" with the version "1.28"
kcl mod add k8s:1.28
# Add the module dependency from the GitHub
kcl mod add --git https://github.com/kcl-lang/konfig --tag v0.4.0
# Add a local dependency
kcl mod add /path/to/another_module`
)
Expand All @@ -43,6 +46,7 @@ func NewModAddCmd(cli *client.KpmClient) *cobra.Command {

cmd.Flags().StringVar(&git, "git", "", "git repository location")
cmd.Flags().StringVar(&tag, "tag", "", "git repository tag")
cmd.Flags().StringVar(&commit, "commit", "", "git repository commit")

return cmd
}
Expand Down Expand Up @@ -115,14 +119,14 @@ func ModAdd(cli *client.KpmClient, args []string) error {

// parseAddOptions will parse the user cli inputs.
func parseAddOptions(cli *client.KpmClient, localPath string, args []string) (*opt.AddOptions, error) {
// parse from 'kpm add -git https://xxx/xxx.git -tag v0.0.1'.
if len(args) == 0 {
return &opt.AddOptions{
LocalPath: localPath,
RegistryOpts: opt.RegistryOptions{
Git: &opt.GitOptions{
Url: git,
Tag: tag,
Url: git,
Tag: tag,
Commit: commit,
},
},
}, nil
Expand Down

0 comments on commit 7987b84

Please sign in to comment.