CLI tool for comparing tree like structures
MIT License
A tool for comparing Tree like files, specifically JSON and YAML
Right now, simply go to the releases page and download
the latest binary to your prefered directory in your path (like /usr/local/bin
). This applies for both
windows and linux
If you have snap
on your system, you can install it with
$ sudo snap install --beta tdiff # I hope to be able to consider it out of beta soon
$ brew tap aleandros/tdiff
$ brew install tdiff
Usage: tdiff [OPTION]... [SOURCE] <TARGET>
Identifies the differences between two tree-like file structures.
If <TARGET>
is not present, input is assumed to come from STDIN.
At this moment, only JSON and YAML are supported.
An exit status of 1 indicates an error in the program. An exit status of 127 indicates that there are differences between source and target. An exit status of 0 indicates no changes
Example output:
$ tdiff shard.yml shard.lock
- name: tdiff
* version: changed type from string to float
- authors: ["Edgar Cabrera <[email protected]>"]
- targets: {"tdiff" => {"main" => "main.cr"}}
- crystal: 0.34.0
- license: MIT
- development_dependencies: {"ameba" => {"github" => "crystal-ameba/ameba", "version" => "~> 0.12.0"}}
+ shards: {"ameba" => {"github" => "crystal-ameba/ameba", "version" => "0.12.1"}}
Add it to your application shards:
dependencies:
tdiff:
github: aleandros/tdiff
It just requires a couple of IO objects, containing the YAML or JSON data,
and returns a list of Tdiff:Core::Result
objects.
require "tdiff"
comparator = Tdiff.compare(File.open('target_1.yml'), File.open('target_2.yml'))
comparator.compare
comparator.results.each do |result|
puts "#{result.path.join(".")}: #{result.difference.reason}"
end
If any of the inputs cannot be parsed, this method will raise a Tdiff::Exception
error.
This is a pretty standard crystal project. So install crystal with your prefered method.
First install dependencies with shards install
.
Remember to run:
crystal spec
crystal tool format
bin/ameba
This will be checked by CI but still save yourself some time.
You can find the documentation here
Tdiff::Core
to be used as a librarygit checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)