Skip to content

Commit

Permalink
Merge pull request #60 from Peefy/init-version-option
Browse files Browse the repository at this point in the history
feat: add version flag for the kcl mod init command
  • Loading branch information
Peefy authored Mar 15, 2024
2 parents caefdae + 00cf5f2 commit 8a804be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 9 additions & 5 deletions cmd/kcl/commands/mod_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ const (
kcl mod init
# Init one kcl module with the name
kcl mod init package-name`
kcl mod init package-name
# Init one kcl module with the name and version
kcl mod init package-name --version 0.1.0`
)

// NewModInitCmd returns the mod init command.
func NewModInitCmd(cli *client.KpmClient) *cobra.Command {
initOpts := opt.InitOptions{}
cmd := &cobra.Command{
Use: "init",
Short: "initialize new module in current directory",
Expand Down Expand Up @@ -54,10 +58,8 @@ func NewModInitCmd(cli *client.KpmClient) *cobra.Command {
}
}

initOpts := opt.InitOptions{
Name: pkgName,
InitPath: pkgRootPath,
}
initOpts.Name = pkgName
initOpts.InitPath = pkgRootPath

err = initOpts.Validate()
if err != nil {
Expand Down Expand Up @@ -89,5 +91,7 @@ func NewModInitCmd(cli *client.KpmClient) *cobra.Command {
SilenceUsage: true,
}

cmd.Flags().StringVar(&initOpts.Version, "version", "", "init module version")

return cmd
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
kcl-lang.io/kcl-go v0.8.0
kcl-lang.io/kcl-openapi v0.6.0
kcl-lang.io/kcl-playground v0.5.1
kcl-lang.io/kpm v0.8.1
kcl-lang.io/kpm v0.8.2-0.20240315081549-f70f6ff67ef5
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1741,8 +1741,8 @@ kcl-lang.io/kcl-openapi v0.6.0 h1:qg/c0+e2Q2eyejarVvm3FCxRQ4mIPXqEBoheazHqsAg=
kcl-lang.io/kcl-openapi v0.6.0/go.mod h1:Ai9mFztCVKkRSFabczO/r5hCNdqaNtAc2ZIRxTeV0Mk=
kcl-lang.io/kcl-playground v0.5.1 h1:MKQQUHgt4+2QyU2NVwa73oksOaBJGDi4keGoggA0MiU=
kcl-lang.io/kcl-playground v0.5.1/go.mod h1:IFmnlw7m011ccX8OidMUfnnN2u/TWdtQGxyABRTbmow=
kcl-lang.io/kpm v0.8.1 h1:vJNRhlDSfD6bFAPGeRxHKbu3Ml9LesuMbMwGy/rH7/8=
kcl-lang.io/kpm v0.8.1/go.mod h1:3atE1tEbsSPaAuKslkADH1HTDi7SMWlDWllmuk2XsBA=
kcl-lang.io/kpm v0.8.2-0.20240315081549-f70f6ff67ef5 h1:YNRiCo/mB3Xh3qhWQrxf1rJ4T2rTx5lDgPDIKbnsRgM=
kcl-lang.io/kpm v0.8.2-0.20240315081549-f70f6ff67ef5/go.mod h1:3atE1tEbsSPaAuKslkADH1HTDi7SMWlDWllmuk2XsBA=
kcl-lang.io/lib v0.8.0 h1:bzMzPpaXaAxWO9JP0B7eI2ZFOYfojdEYUMtNGlUrPx4=
kcl-lang.io/lib v0.8.0/go.mod h1:ubsalGXxJaa5II/EsHmsI/tL2EluYHIcW+BwzQPt+uY=
oras.land/oras-go v1.2.3 h1:v8PJl+gEAntI1pJ/LCrDgsuk+1PKVavVEPsYIHFE5uY=
Expand Down

0 comments on commit 8a804be

Please sign in to comment.