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

36 lines
756 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.
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
require "twenty-backend"
require "twenty-frontend"
2023-12-09 22:46:13 +01:00
require_relative "twenty-cli/command"
end