Comments (7)
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.
@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.
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.
Yeah, it def shouldn't be the default behavior.
from nbtlib.
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.
The --find
option is now in version 1.10 https://github.com/vberlier/nbtlib/releases/tag/v1.10.0
from nbtlib.
from nbtlib.
Related Issues (20)
- servers.dat issues. HOT 1
- Root creates an spurious Compound that is not in actual NBT data HOT 19
- `Path` cannot add or init integers, only strings and other Paths HOT 2
- Preserve type on List.copy() and slicing HOT 5
- Improve `read_numeric()` to vastly increase `parse()` performance for all tags HOT 4
- Array tags are immutable views, not editable ndarrays HOT 9
- `File` is not writing the trailing End tag HOT 4
- `nbtlib 2.0` HOT 16
- Add `Path.from_parts()` or similar to allow tuple constructor like `pathlib.Path` HOT 8
- Investigate schema improvements/autocast HOT 7
- How to add a server in servers.dat? HOT 2
- Iterate NBT HOT 4
- Can't read FTB Quests NBT HOT 2
- How to get JSON info as intuitively as CLI? HOT 1
- if just have one value in list ,i got error HOT 2
- Use modified utf-8 for encoding and decoding strings HOT 2
- nbtlib.Long can not set 64bytes value HOT 1
- a minor issue of index of list.
- How to use/initialize nbtlib.ByteArray? HOT 1
- Jython compatibility
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nbtlib.