Skip to content

Commit 00cf5f2

Browse files
committed
feat: add version flag for the kcl mod init command
Signed-off-by: peefy <[email protected]>
1 parent caefdae commit 00cf5f2

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

Diff for: cmd/kcl/commands/mod_init.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ const (
2121
kcl mod init
2222
2323
# Init one kcl module with the name
24-
kcl mod init package-name`
24+
kcl mod init package-name
25+
26+
# Init one kcl module with the name and version
27+
kcl mod init package-name --version 0.1.0`
2528
)
2629

2730
// NewModInitCmd returns the mod init command.
2831
func NewModInitCmd(cli *client.KpmClient) *cobra.Command {
32+
initOpts := opt.InitOptions{}
2933
cmd := &cobra.Command{
3034
Use: "init",
3135
Short: "initialize new module in current directory",
@@ -54,10 +58,8 @@ func NewModInitCmd(cli *client.KpmClient) *cobra.Command {
5458
}
5559
}
5660

57-
initOpts := opt.InitOptions{
58-
Name: pkgName,
59-
InitPath: pkgRootPath,
60-
}
61+
initOpts.Name = pkgName
62+
initOpts.InitPath = pkgRootPath
6163

6264
err = initOpts.Validate()
6365
if err != nil {
@@ -89,5 +91,7 @@ func NewModInitCmd(cli *client.KpmClient) *cobra.Command {
8991
SilenceUsage: true,
9092
}
9193

94+
cmd.Flags().StringVar(&initOpts.Version, "version", "", "init module version")
95+
9296
return cmd
9397
}

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
kcl-lang.io/kcl-go v0.8.0
1111
kcl-lang.io/kcl-openapi v0.6.0
1212
kcl-lang.io/kcl-playground v0.5.1
13-
kcl-lang.io/kpm v0.8.1
13+
kcl-lang.io/kpm v0.8.2-0.20240315081549-f70f6ff67ef5
1414
)
1515

1616
require (

Diff for: go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1741,8 +1741,8 @@ kcl-lang.io/kcl-openapi v0.6.0 h1:qg/c0+e2Q2eyejarVvm3FCxRQ4mIPXqEBoheazHqsAg=
17411741
kcl-lang.io/kcl-openapi v0.6.0/go.mod h1:Ai9mFztCVKkRSFabczO/r5hCNdqaNtAc2ZIRxTeV0Mk=
17421742
kcl-lang.io/kcl-playground v0.5.1 h1:MKQQUHgt4+2QyU2NVwa73oksOaBJGDi4keGoggA0MiU=
17431743
kcl-lang.io/kcl-playground v0.5.1/go.mod h1:IFmnlw7m011ccX8OidMUfnnN2u/TWdtQGxyABRTbmow=
1744-
kcl-lang.io/kpm v0.8.1 h1:vJNRhlDSfD6bFAPGeRxHKbu3Ml9LesuMbMwGy/rH7/8=
1745-
kcl-lang.io/kpm v0.8.1/go.mod h1:3atE1tEbsSPaAuKslkADH1HTDi7SMWlDWllmuk2XsBA=
1744+
kcl-lang.io/kpm v0.8.2-0.20240315081549-f70f6ff67ef5 h1:YNRiCo/mB3Xh3qhWQrxf1rJ4T2rTx5lDgPDIKbnsRgM=
1745+
kcl-lang.io/kpm v0.8.2-0.20240315081549-f70f6ff67ef5/go.mod h1:3atE1tEbsSPaAuKslkADH1HTDi7SMWlDWllmuk2XsBA=
17461746
kcl-lang.io/lib v0.8.0 h1:bzMzPpaXaAxWO9JP0B7eI2ZFOYfojdEYUMtNGlUrPx4=
17471747
kcl-lang.io/lib v0.8.0/go.mod h1:ubsalGXxJaa5II/EsHmsI/tL2EluYHIcW+BwzQPt+uY=
17481748
oras.land/oras-go v1.2.3 h1:v8PJl+gEAntI1pJ/LCrDgsuk+1PKVavVEPsYIHFE5uY=

0 commit comments

Comments
 (0)