diff --git a/cmd/kcl/commands/mod_init.go b/cmd/kcl/commands/mod_init.go index aadd570..46bdb0b 100644 --- a/cmd/kcl/commands/mod_init.go +++ b/cmd/kcl/commands/mod_init.go @@ -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", @@ -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 { @@ -89,5 +91,7 @@ func NewModInitCmd(cli *client.KpmClient) *cobra.Command { SilenceUsage: true, } + cmd.Flags().StringVar(&initOpts.Version, "version", "", "init module version") + return cmd } diff --git a/go.mod b/go.mod index e838f6c..a43e60d 100644 --- a/go.mod +++ b/go.mod @@ -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 ( diff --git a/go.sum b/go.sum index 3575276..86f022e 100644 --- a/go.sum +++ b/go.sum @@ -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=