• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kcl-lang / cli / 33302197123
26%
main: 31%

Build:
Build:
LAST BUILD BRANCH: feat/issue-2047-xml-format
DEFAULT BRANCH: main
Ran 30 Aug 2026 08:45AM UTC
Jobs 1
Files 11
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

30 Aug 2026 08:40AM UTC coverage: 25.837% (-1.9%) from 27.691%
33302197123

Pull #378

github

Peefy
feat(cli): add --identifier flag to kcl import for assigning data to a name (fixes #1868)

Adds a new `-i` / `--identifier` flag to `kcl import` that wraps the generated
free-standing dict literal in `<name> = { ... }`, so the result can be
referenced as `import <file> as ns; ns.<name>` from another KCL file.

Behaviour:

* Data modes (`json`, `yaml`, `toml`, and `auto` when every input has a
  data extension) wrap the literal.
* Schema modes (`jsonschema`, `gostruct`, `openapi`, `crd`,
  `terraformschema`) ignore the flag because their output contains
  named `schema ...:` declarations that cannot be assigned to a name.

Example:

    $ kcl import -m yaml -i userData data.yaml
    $ cat user_data.k
    """
    This file was generated by the KCL auto-gen tool. DO NOT EDIT.
    Editing this file might prove futile when you re-run the KCL auto-gen generate command.
    """

    userData = {
            name = "alice"
            age = 30
    }

    $ cat consumer.k
    import user_data as ud
    result = ud.userData.name
    $ kcl run consumer.k
    result: alice

The implementation adds three small helpers in `pkg/options/import.go`:
`writeGenKcl`, `shouldWrapData`, and `wrapDataLiteral`. The latter two are
pure functions that don't depend on kcl-go internals, so they remain
straightforward to follow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Peefy <xpf6677@163.com>
Pull Request #378: feat(cli): add --identifier flag to kcl import for assigning data to a name

0 of 68 new or added lines in 1 file covered. (0.0%)

247 of 956 relevant lines covered (25.84%)

0.28 hits per line

Uncovered Changes

Lines Coverage ∆ File
68
0.0
0.0% pkg/options/import.go
Jobs
ID Job ID Ran Files Coverage
1 33302197123.1 30 Aug 2026 08:45AM UTC 11
25.84
GitHub Action Run
Source Files on build 33302197123
  • Tree
  • List 11
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Pull Request #378
  • PR Base - main (#33296940384)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc