Class: Tracker::Cli::Command::Destroy
- Inherits:
-
Object
- Object
- Tracker::Cli::Command::Destroy
- Defined in:
- lib/tracker/cli/command/destroy.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#cli ⇒ Object
readonly
Returns the value of attribute cli.
Instance Method Summary collapse
- #destroy_project(object_id:, **arguments) ⇒ Object
-
#initialize(cli:, object_type:, **arguments) ⇒ Destroy
constructor
A new instance of Destroy.
Constructor Details
#initialize(cli:, object_type:, **arguments) ⇒ Destroy
Returns a new instance of Destroy.
7 8 9 10 11 12 13 14 |
# File 'lib/tracker/cli/command/destroy.rb', line 7 def initialize(cli: , object_type: , **arguments) @cli = cli @arguments = arguments case object_type when 'project' then destroy_project(**arguments) end end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
5 6 7 |
# File 'lib/tracker/cli/command/destroy.rb', line 5 def arguments @arguments end |
#cli ⇒ Object (readonly)
Returns the value of attribute cli.
5 6 7 |
# File 'lib/tracker/cli/command/destroy.rb', line 5 def cli @cli end |
Instance Method Details
#destroy_project(object_id:, **arguments) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tracker/cli/command/destroy.rb', line 16 def destroy_project(object_id: , **arguments) res = cli.connection.get("projects/#{object_id}") if res.status != 200 $stderr.print "#{res.body['error']}\n" $stderr.print "#{res.body['general_problem']}\n" $stderr.print "#{res.body['possible_fix']}\n" return end project = res.body $stderr.print "Warning: Destructive Action!\n\n" confirm = View::Confirm.new(project['name']) if confirm.confirmed? print cli.connection.delete("projects/#{object_id}").body end end |