Skip to content

Instantly share code, notes, and snippets.

@aliou
Last active December 10, 2015 16:49
Show Gist options
  • Save aliou/4463869 to your computer and use it in GitHub Desktop.
Save aliou/4463869 to your computer and use it in GitHub Desktop.
Cheddar (cheddarapp.com) lists backup.

Quick command line interface for Cheddar. Uses the vermonster gem, install with:

gem install vermonster

The config file is located at ~/.config/cheddar/config is formated like a regular yaml file:

client_id: xxxxxxx
client_secret: xxxxxxx
user_token: xxxxxxx
require 'vermonster'
require 'json'
require 'yaml'
config = YAML.load_file("#{ENV['HOME']}/.config/cheddar/config")
cheddar = Vermonster::Client.new(:id => config["client_id"],
:secret => config["client_secret"])
cheddar.use_token!(config["user_token"])
lists = []
cheddar.lists.all.each do |list|
if list["archived_at"].nil?
current_tasks = []
cheddar.lists.find(list["id"].to_i).tasks.each do |task|
current_tasks << task["text"]
end
current = {}
current["id"] = list["id"].to_i
current["title"] = list["title"]
current["tasks"] = current_tasks
lists << current unless current_tasks.empty?
end
end
File.open "cheddar-bkp.json", "w" do |file|
file.write JSON.pretty_generate lists
end
File.open "cheddar-bkp.min.json", "w" do |file|
file.write JSON.generate lists
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment