Class: ShapeupCli::Commands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/shapeup_cli/commands/base.rb

Direct Known Subclasses

Auth, Comments, ConfigCmd, Cycle, Issues, MyWork, Orgs, Pitches, Scopes, Search, Setup, Tasks

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Base

Returns a new instance of Base.



20
21
22
23
24
25
# File 'lib/shapeup_cli/commands/base.rb', line 20

def initialize(args)
  @mode, remaining = Output.parse_mode(args)
  @agent_help = @mode == :agent && remaining.include?("--help")
  remaining.delete("--help") if @agent_help
  @org_id, @remaining = extract_flags(remaining)
end

Class Method Details

.metadataObject

Override in subclasses to define structured command metadata



16
17
18
# File 'lib/shapeup_cli/commands/base.rb', line 16

def self.
  { command: name.split("::").last.downcase, description: "No metadata defined" }
end

.run(args) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/shapeup_cli/commands/base.rb', line 6

def self.run(args)
  instance = new(args)
  if instance.agent_help?
    puts JSON.pretty_generate(instance.class.)
  else
    instance.execute
  end
end

Instance Method Details

#agent_help?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/shapeup_cli/commands/base.rb', line 27

def agent_help?
  @agent_help
end