Giter VIP home page Giter VIP logo

Comments (7)

vberlier avatar vberlier commented on July 21, 2024

That's a good idea! I'm thinking about adding a positional argument that would let you specify an nbt path.

This would look a bit like this:

$ nbt -r tests/nbt_files/bigtest.nbt 'Level."listTest (compound)"[{name: "Compound tag #0"}]'
{name: "Compound tag #0", created-on: 1264099775885L}

Combined with a new flag that would expose the functionality of the unpack() method you could also turn it into json:

$ nbt -r tests/nbt_files/bigtest.nbt 'Level."listTest (compound)"[0]' --unpack json
{"name": "Compound tag #0", "created-on": 1264099775885}
$ nbt -r tests/nbt_files/bigtest.nbt 'Level."listTest (compound)"[].name' --unpack json
"Compound tag #0"
"Compound tag #1"
$ nbt -r tests/nbt_files/bigtest.nbt 'Level."listTest (compound)"[].name' --unpack
Compound tag #0
Compound tag #1

What do you think?

from nbtlib.

crabdancing avatar crabdancing commented on July 21, 2024

@vberlier That's a good approach! :D

It might also be a good idea to have the option of just recursively searching for a particular tag for a more heuristical approach when the user doesn't know where in the hierarchy it is. :)

from nbtlib.

vberlier avatar vberlier commented on July 21, 2024

I see. Maybe when the path doesn't yield anything we could recurse into the tag hierarchy and try again until something matches. This would be pretty costly if the path specified was absolute and the tag just didn't exist, so the recursive behavior could be enabled by a flag, for when you know the tag exists but not where.

from nbtlib.

crabdancing avatar crabdancing commented on July 21, 2024

Yeah, it def shouldn't be the default behavior.

from nbtlib.

vberlier avatar vberlier commented on July 21, 2024

Just added the --path, --unpack and --json options to the cli. I'm planning to add a --find option that's going to do the recursive matching we talked about.

from nbtlib.

vberlier avatar vberlier commented on July 21, 2024

The --find option is now in version 1.10 https://github.com/vberlier/nbtlib/releases/tag/v1.10.0

from nbtlib.

crabdancing avatar crabdancing commented on July 21, 2024

from nbtlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.