Skip to content

Commit

Permalink
Merge pull request #105 from zong-zhe/unify-run-cli
Browse files Browse the repository at this point in the history
feat: unify the kcl run cli
  • Loading branch information
Peefy authored Jul 11, 2024
2 parents 10e2833 + 2bbf912 commit 5cd6bc7
Show file tree
Hide file tree
Showing 150 changed files with 592 additions and 109 deletions.
8 changes: 8 additions & 0 deletions cmd/kcl/commands/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ func appendLangFlags(o *options.RunOptions, flags *pflag.FlagSet) {
"Specify the path selectors")
flags.StringVarP(&o.Output, "output", "o", "",
"Specify the YAML/JSON output file path")
flags.StringVarP(&o.Git, "git", "", "",
"Specify the KCL module git url")
flags.StringVarP(&o.Oci, "oci", "", "",
"Specify the KCL module oci url")
flags.StringVarP(&o.Tag, "tag", "t", "",
"Specify the tag for the OCI or Git artifact")
flags.StringVarP(&o.Commit, "commit", "c", "",
"Specify the commit for the Git artifact")
flags.StringVarP(&o.Branch, "branch", "b", "",
"Specify the branch for the Git artifact")
flags.StringVar(&o.Format, "format", "yaml",
"Specify the output format")
flags.BoolVarP(&o.DisableNone, "disable_none", "n", false,
Expand Down
2 changes: 1 addition & 1 deletion cmd/kcl/commands/mod_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
# Pull the module from the OCI Registry by oci url
kcl mod pull oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
# Pull the module from the GitHub by flag
# Pull the module from the Git by flag
kcl mod pull --git https://github.com/kcl-lang/konfig --tag v0.4.0
# Pull the module from the OCI Registry by flag
Expand Down
16 changes: 11 additions & 5 deletions cmd/kcl/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const (
For example, 'kcl run path/to/kcl.k' will run the file named path/to/kcl.k
`
runExample = ` # Run a single file and output YAML
runExample = ` # Run the current package
kcl run
# Run a single file and output YAML
kcl run path/to/kcl.k
# Run a single file and output JSON
Expand All @@ -25,13 +28,16 @@ For example, 'kcl run path/to/kcl.k' will run the file named path/to/kcl.k
kcl run path/to/kcl1.k path/to/kcl2.k
# Run OCI packages
kcl run oci://ghcr.io/kcl-lang/helloworld
kcl run oci://ghcr.io/kcl-lang/helloworld --tag 0.1.0
# Run remote Git repo
kcl run https://github.com/kcl-lang/flask-demo-kcl-manifests
kcl run git://github.com/kcl-lang/flask-demo-kcl-manifests --commit ade147b
# Run OCI packages by flag
kcl run --oci https://ghcr.io/kcl-lang/helloworld --tag 0.1.0
# Run the current package
kcl run`
# Run remote module from Git with branch repo by flag
kcl run --git https://github.com/kcl-lang/flask-demo-kcl-manifests --branch main`
)

// NewRunCmd returns the run command.
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
kcl-lang.io/kcl-go v0.9.1
kcl-lang.io/kcl-openapi v0.6.3
kcl-lang.io/kcl-playground v0.5.1
kcl-lang.io/kpm v0.9.0
kcl-lang.io/kpm v0.9.1-0.20240710094621-7c6b74f8b24c
)

require (
Expand All @@ -27,7 +27,7 @@ require (
github.com/chainguard-dev/git-urls v1.0.2 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containers/image/v5 v5.31.0 // indirect
github.com/containers/image/v5 v5.31.1 // indirect
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
github.com/containers/ocicrypt v1.1.10 // indirect
github.com/containers/storage v1.54.0 // indirect
Expand All @@ -44,7 +44,7 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.4 // indirect
github.com/hashicorp/go-getter v1.7.5 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
Expand Down Expand Up @@ -72,6 +72,7 @@ require (
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
kcl-lang.io/lib v0.9.1 // indirect
)

require (
Expand Down Expand Up @@ -124,7 +125,7 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-yaml v1.11.3
github.com/gofrs/flock v0.11.0 // indirect
github.com/gofrs/flock v0.12.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand Down Expand Up @@ -204,7 +205,6 @@ require (
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
kcl-lang.io/lib v0.9.1 // indirect
oras.land/oras-go v1.2.5 // indirect
oras.land/oras-go/v2 v2.5.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5Z
github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0=
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/containers/image/v5 v5.31.0 h1:eDFVlz5XaYICxe9dXpf23htEKvyosgkl62mJlIATXE4=
github.com/containers/image/v5 v5.31.0/go.mod h1:5QfOqSackPkSbF7Qxc1DnVNnPJKQ+KWLkfEfDpK590Q=
github.com/containers/image/v5 v5.31.1 h1:3x9soI6Biml/GiDLpkSmKrkRSwVGctxu/vONpoUdklA=
github.com/containers/image/v5 v5.31.1/go.mod h1:5QfOqSackPkSbF7Qxc1DnVNnPJKQ+KWLkfEfDpK590Q=
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA=
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
github.com/containers/ocicrypt v1.1.10 h1:r7UR6o8+lyhkEywetubUUgcKFjOWOaWz8cEBrCPX0ic=
Expand Down Expand Up @@ -485,8 +485,8 @@ github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG
github.com/goccy/go-yaml v1.11.3 h1:B3W9IdWbvrUu2OYQGwvU1nZtvMQJPBKgBUuweJjLj6I=
github.com/goccy/go-yaml v1.11.3/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/flock v0.11.0 h1:AGFQxrpWd8ezw60AvLWIPbxMydNfF8564pwH3FCty0g=
github.com/gofrs/flock v0.11.0/go.mod h1:FirDy1Ing0mI2+kB6wk+vyyAH+e6xiE+EYA0jnzV9jc=
github.com/gofrs/flock v0.12.0 h1:xHW8t8GPAiGtqz7KxiSqfOEXwpOaqhpYZrTE2MQBgXY=
github.com/gofrs/flock v0.12.0/go.mod h1:FirDy1Ing0mI2+kB6wk+vyyAH+e6xiE+EYA0jnzV9jc=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
Expand Down Expand Up @@ -632,8 +632,8 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-getter v1.7.4 h1:3yQjWuxICvSpYwqSayAdKRFcvBl1y/vogCxczWSmix0=
github.com/hashicorp/go-getter v1.7.4/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744=
github.com/hashicorp/go-getter v1.7.5 h1:dT58k9hQ/vbxNMwoI5+xFYAJuv6152UNvdHokfI5wE4=
github.com/hashicorp/go-getter v1.7.5/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
Expand Down Expand Up @@ -1691,8 +1691,8 @@ kcl-lang.io/kcl-openapi v0.6.3 h1:6Br0IBaNshRvBfmaH22Zv1miVEt6FWlmh2v/wBLb194=
kcl-lang.io/kcl-openapi v0.6.3/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.9.0 h1:ISbsPw1GWhe6Wt4MgfY0WZEjvb5NI43O+5dmH0CUoiM=
kcl-lang.io/kpm v0.9.0/go.mod h1:+8dz5o9l1DEzEYdfRetnAXhrfqKdzTQb3s99DubbHhk=
kcl-lang.io/kpm v0.9.1-0.20240710094621-7c6b74f8b24c h1:qCz15r0JFyB3AEYlSY2Aq1dPbT90EWJga4EMMMylyTc=
kcl-lang.io/kpm v0.9.1-0.20240710094621-7c6b74f8b24c/go.mod h1:6oKrOP+tNqteyfdlEy1VH8xvy7Eg3FL6q1CHxM4tjc0=
kcl-lang.io/lib v0.9.1 h1:wPcTYFZo4XQZYHPrEoQjV2SU++2jz2y/1Khfqj2/8DA=
kcl-lang.io/lib v0.9.1/go.mod h1:tu+tzwGgHLzYZSIxUG/ntipStrxZd6OvutWYPTxS7cs=
oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo=
Expand Down
Loading

0 comments on commit 5cd6bc7

Please sign in to comment.