dolphins7.skeleton/twenty-cli/lib/twenty/cli.rb

38 lines
762 B
Ruby
Raw Normal View History

module Twenty
2023-12-09 22:37:39 +01:00
module DB
require "json"
DEFAULTS = { connections: [] }
##
# FIXME:
# The following methods are required by
# both twenty-cli, and twenty-backend. Eventually
# they should be moved into their own package.
extend self
def home
File.join Dir.home, ".local", "share", "twenty"
end
def database
Ryo.from DEFAULTS.dup.merge(JSON.parse(database_path))
rescue
Ryo.from(DEFAULTS.dup)
end
def database_path
File.join(home, "database.json")
end
def save!(db)
File.binwrite database_path,
JSON.dump(Ryo.table_of(db, recursive: true))
end
end
2023-12-08 19:27:00 +01:00
require "twenty/backend"
require "twenty/frontend"
2023-12-08 17:40:29 +01:00
require_relative "command"
end