Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cat: QoL for expanded mode #734

Closed
Sainan opened this issue Mar 4, 2024 · 0 comments
Closed

Cat: QoL for expanded mode #734

Sainan opened this issue Mar 4, 2024 · 0 comments
Labels
improvement Improves existing behavior
Milestone

Comments

@Sainan
Copy link
Member

Sainan commented Mar 4, 2024

A simple metatable like this would be pretty unintrusive (= invisible to dumpvar & for loops) and would massively simplify usage of CaT in expanded mode:

local { cat } = require "*"

local cat_mt = {
    __index = function(data, key)
        for data as node do
            if node.name == key then
                return node
            end
        end
        return nil
    end
}

local data = cat.decode([[
Foo: Foobar
Bar: Barfoo
]], "expanded")
setmetatable(data, cat_mt)

print(data["Foo"].value) --> Foobar

I'd say once this is addressed, expanded mode could be the default (as per #733).

@Sainan Sainan added the improvement Improves existing behavior label Mar 4, 2024
@Sainan Sainan added this to the 0.9.0 milestone Mar 4, 2024
@Sainan Sainan closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improves existing behavior
Projects
None yet
Development

No branches or pull requests

1 participant