cli: add "twenty console"

This commit is contained in:
0x1eef 2023-12-25 23:12:57 -03:00
parent 67a3cc7ead
commit e076598f13
5 changed files with 34 additions and 0 deletions

View file

@ -23,6 +23,7 @@ rather than in the cloud.
connect Connect a project to twenty.
disconnect Disconnect a project from twenty.
migrate Migrate the database.
console Start the twenty developer console.
## Install

View file

@ -20,6 +20,9 @@ when "disconnect"
when "migrate"
wait spawn("migrate", *ARGV[1..])
exit $?.exitstatus
when "console"
wait spawn("console", *ARGV[1..])
exit $?.exitstatus
else
warn "Usage: twenty COMMAND [OPTIONS]\n\n" \
"Commands:\n" \
@ -28,4 +31,5 @@ else
" connect Connect a project to twenty.\n" \
" disconnect Disconnect a project from twenty.\n" \
" migrate Migrate the database.\n" \
" console Start the twenty developer console.\n" \
end

View file

@ -6,4 +6,5 @@ class Twenty::Command < Cmd
require_relative "command/connect"
require_relative "command/disconnect"
require_relative "command/migrate"
require_relative "command/console"
end

View file

@ -0,0 +1,16 @@
class Twenty::Command::Console < Twenty::Command
set_banner usage: "twenty console [OPTIONS]",
description: "Start the twenty developer console"
def run
options = parse_options(argv)
options.help ? show_help : run_command
end
private
def run_command
require "irb"
TOPLEVEL_BINDING.irb
end
end

View file

@ -0,0 +1,12 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
libdir = File.expand_path File.join(__dir__, "..", "..", "lib")
require File.join(libdir, "twenty-cli")
##
# main
def main(argv)
Twenty::Command::Console.new(argv).run
end
main(ARGV)