@@ -42,8 +42,17 @@ const (
4242 # Add the sub module dependency named "helloworld" from the Git repo by the tag flag with ssh url
4343 kcl mod add helloworld --git ssh://github.com/kcl-lang/modules --tag v0.1.0
4444
45+ # Add the sub module dependency named "cc" with version "0.0.1" from the Git repo by the commit flag with ssh url
46+ kcl mod add cc:0.0.1 --git https://github.com/kcl-lang/flask-demo-kcl-manifests --commit 8308200
47+
4548 # Add the module dependency from the OCI registry named "" by the tag flag
46- kcl mod add --oci https://ghcr.io/kcl-lang/helloworld --tag 0.1.0`
49+ kcl mod add --oci https://ghcr.io/kcl-lang/helloworld --tag 0.1.0
50+
51+ # Add the sub module dependency named "subhelloworld" from the OCI registry by the tag flag
52+ kcl mod add subhelloworld --oci https://ghcr.io/kcl-lang/helloworld --tag 0.1.4
53+
54+ # Add the sub module dependency named "subhelloworld" with version "0.0.1" from the OCI registry by the tag flag
55+ kcl mod add subhelloworld:0.0.1 --oci https://ghcr.io/kcl-lang/helloworld --tag 0.1.4`
4756)
4857
4958// NewModAddCmd returns the mod add command.
@@ -100,7 +109,10 @@ func ModAdd(cli *client.KpmClient, args []string) error {
100109 return err
101110 }
102111
103- kclPkg , err := pkg .LoadKclPkg (pwd )
112+ kclPkg , err := pkg .LoadKclPkgWithOpts (
113+ pkg .WithPath (pwd ),
114+ pkg .WithSettings (cli .GetSettings ()),
115+ )
104116 if err != nil {
105117 return err
106118 }
@@ -110,13 +122,13 @@ func ModAdd(cli *client.KpmClient, args []string) error {
110122 return err
111123 }
112124
113- addOpts , err := parseAddOptions (cli , globalPkgPath , args )
125+ source , err := ParseSourceFromArgs (cli , args )
114126 if err != nil {
115127 return err
116128 }
117129
118- if addOpts . RegistryOpts .Local != nil {
119- absAddPath , err := filepath .Abs (addOpts . RegistryOpts .Local .Path )
130+ if source .Local != nil {
131+ absAddPath , err := filepath .Abs (source .Local .Path )
120132 if err != nil {
121133 return reporter .NewErrorEvent (reporter .Bug , err , "internal bugs, please contact us to fix it." )
122134 }
@@ -128,12 +140,10 @@ func ModAdd(cli *client.KpmClient, args []string) error {
128140 }
129141 }
130142
131- err = addOpts .Validate ()
132- if err != nil {
133- return err
134- }
135-
136- _ , err = cli .AddDepWithOpts (kclPkg , addOpts )
143+ err = cli .Add (
144+ client .WithAddKclPkg (kclPkg ),
145+ client .WithAddSource (source ),
146+ )
137147 if err != nil {
138148 return err
139149 }
0 commit comments