diff --git a/twenty-cli/lib/twenty-cli/command.rb b/twenty-cli/lib/twenty-cli/command.rb index f0d46d2..b06c77e 100644 --- a/twenty-cli/lib/twenty-cli/command.rb +++ b/twenty-cli/lib/twenty-cli/command.rb @@ -5,6 +5,7 @@ require "cmd" class Twenty::Command < Cmd ## # mixins + require_relative "command/mixin/common_option_mixin" require_relative "command/mixin/pending_migration_mixin" require_relative "command/mixin/sqlite_connection_mixin" diff --git a/twenty-cli/lib/twenty-cli/command/console.rb b/twenty-cli/lib/twenty-cli/command/console.rb index 987e151..f149265 100644 --- a/twenty-cli/lib/twenty-cli/command/console.rb +++ b/twenty-cli/lib/twenty-cli/command/console.rb @@ -3,6 +3,7 @@ class Twenty::Command::Console < Twenty::Command set_banner usage: "twenty console [OPTIONS]", description: "Start the twenty developer console" + include CommonOptionMixin prepend Twenty::Command::PendingMigrationMixin prepend Twenty::Command::SQLiteConnectionMixin diff --git a/twenty-cli/lib/twenty-cli/command/migrate.rb b/twenty-cli/lib/twenty-cli/command/migrate.rb index c0f1dcd..f1f4aed 100644 --- a/twenty-cli/lib/twenty-cli/command/migrate.rb +++ b/twenty-cli/lib/twenty-cli/command/migrate.rb @@ -3,6 +3,7 @@ class Twenty::Command::Migrate < Twenty::Command set_banner usage: "twenty migrate [OPTIONS]", description: "Migrate the database" + include CommonOptionMixin prepend Twenty::Command::SQLiteConnectionMixin def run diff --git a/twenty-cli/lib/twenty-cli/command/mixin/common_option_mixin.rb b/twenty-cli/lib/twenty-cli/command/mixin/common_option_mixin.rb new file mode 100644 index 0000000..ef935d2 --- /dev/null +++ b/twenty-cli/lib/twenty-cli/command/mixin/common_option_mixin.rb @@ -0,0 +1,13 @@ +class Twenty::Command + module CommonOptionMixin + def self.included(mod) + mod.module_eval do + set_option "-d PATH", + "--database PATH", + "The path to an alternate SQLite3 database", + as: String, + default: nil + end + end + end +end diff --git a/twenty-cli/lib/twenty-cli/command/up.rb b/twenty-cli/lib/twenty-cli/command/up.rb index 5d50a4c..ebfca05 100644 --- a/twenty-cli/lib/twenty-cli/command/up.rb +++ b/twenty-cli/lib/twenty-cli/command/up.rb @@ -3,11 +3,7 @@ class Twenty::Command::Up < Twenty::Command set_banner usage: "twenty up [OPTIONS]", description: "Start the twenty web server" - set_option "-d PATH", - "--database PATH", - "The path to an alternate SQLite3 database", - as: String, - default: nil + include CommonOptionMixin prepend Twenty::Command::PendingMigrationMixin prepend Twenty::Command::SQLiteConnectionMixin