dbohdan / initool

Manipulate INI files from the command line
MIT License
57 stars 6 forks source link

Ability to chain / reading stdin #4

Closed tocklime closed 5 years ago

tocklime commented 5 years ago

It would be nice if there were some provision so I can make (say) 3 edits to the same file, without having to write it out to disk each time.

I can think of a couple of ways to do this:

  1. Allow multiple sets and deletes on a line: initool s myFile.ini path1 key1 value1 s path2 key2 value2 d path3 key3 The argument order gets a bit weird there though, maybe have a new command 'm' for multiple?
  2. Perhaps more simply, allow the program to read stdin. Then I could do initool s myFile.ini path1 key1 value1 | initool s - path2 key2 value2 | ...
    Of course you're re-parsing the file each time then, which might be a problem for huge ini files, but it's no worse than what you'd have to do currently.

Reading stdin would be useful for other things too, I'm sure.

Or have I missed an existing feature?

dbohdan commented 5 years ago

Good idea! I'll implement reading from stdin. The parsing/serialization speed should not be a problem. Even on modest hardware you should be able to a perform a dozen of set operations on 10k lines in under a second.

For option 1 it would be best to switch the argument order from initool s file.ini section key value to initool file.ini s section key value. It would read better in pipelines, too. It's something I'll consider.

dbohdan commented 5 years ago

Done in e5daa7c/release v0.10.0.