diff --git a/README.md b/README.md index e358d69..25a0891 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/twenty-cli/bin/twenty b/twenty-cli/bin/twenty index e60a3de..fa51380 100755 --- a/twenty-cli/bin/twenty +++ b/twenty-cli/bin/twenty @@ -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 diff --git a/twenty-cli/lib/twenty-cli/command.rb b/twenty-cli/lib/twenty-cli/command.rb index 988b00a..49fff41 100644 --- a/twenty-cli/lib/twenty-cli/command.rb +++ b/twenty-cli/lib/twenty-cli/command.rb @@ -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 diff --git a/twenty-cli/lib/twenty-cli/command/console.rb b/twenty-cli/lib/twenty-cli/command/console.rb new file mode 100644 index 0000000..36c7821 --- /dev/null +++ b/twenty-cli/lib/twenty-cli/command/console.rb @@ -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 diff --git a/twenty-cli/libexec/twenty/console b/twenty-cli/libexec/twenty/console new file mode 100755 index 0000000..ec4e10d --- /dev/null +++ b/twenty-cli/libexec/twenty/console @@ -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)