Add -p, --path to connect|disconnect commands
This commit is contained in:
parent
a34c48b26c
commit
527dff3497
2 changed files with 16 additions and 5 deletions
|
@ -3,6 +3,8 @@
|
|||
class Twenty::Command::Connect < Twenty::Command
|
||||
set_banner usage: "twenty connect [OPTIONS]",
|
||||
description: "Connect a project to twenty"
|
||||
set_option "-p PATH", "--path PATH", "The path to a project", default: nil
|
||||
|
||||
prepend Twenty::Command::MigrationMixin
|
||||
prepend Twenty::Command::SQLiteMixin
|
||||
prepend Twenty::Command::RescueMixin
|
||||
|
@ -15,9 +17,15 @@ class Twenty::Command::Connect < Twenty::Command
|
|||
private
|
||||
|
||||
def run_command(options)
|
||||
Twenty::Project.create(
|
||||
name: File.basename(Dir.getwd),
|
||||
path: Dir.getwd
|
||||
path = options.path ? File.expand_path(options.path) : Dir.getwd
|
||||
if File.exist?(path)
|
||||
project = Twenty::Project.create(
|
||||
name: File.basename(path),
|
||||
path:,
|
||||
)
|
||||
warn "[-] '#{project.name}' connected"
|
||||
else
|
||||
abort "[x] The path (#{path}) does not exist"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
class Twenty::Command::Disconnect < Twenty::Command
|
||||
set_banner usage: "twenty disconnect [OPTIONS]",
|
||||
description: "Disconnect a project from twenty"
|
||||
set_option "-p PATH", "--path PATH", "The path to a project", default: nil
|
||||
prepend Twenty::Command::MigrationMixin
|
||||
prepend Twenty::Command::SQLiteMixin
|
||||
prepend Twenty::Command::RescueMixin
|
||||
|
@ -15,9 +16,11 @@ class Twenty::Command::Disconnect < Twenty::Command
|
|||
private
|
||||
|
||||
def run_command(options)
|
||||
path = options.path ? File.expand_path(options.path) : Dir.getwd
|
||||
Twenty::Project
|
||||
.where(path: Dir.getwd)
|
||||
.where(path:)
|
||||
.first!
|
||||
.destroy
|
||||
warn "[-] '#{File.basename(path)}' disconnected"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue