Module: Rubyists::Linear::CLI::CommonOptions

Included in:
Console, Issue::Create, Issue::Develop, Issue::List, Issue::Pr, Issue::Take, Issue::Update, Team::List, Version, WhoAmI
Defined in:
lib/linear/cli/common_options.rb

Overview

The CommonOptions module contains common options for all commands

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



8
9
10
11
12
# File 'lib/linear/cli/common_options.rb', line 8

def self.included(mod)
  mod.instance_eval do
    extend Rubyists::Linear::CLI::Watcher
  end
end

Instance Method Details

#display(subject, options) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/linear/cli/common_options.rb', line 14

def display(subject, options)
  return puts(JSON.pretty_generate(subject)) if options[:output] == 'json'
  return subject.each { |s| s.display(options) } if subject.respond_to?(:each)
  unless subject.respond_to?(:display)
    raise SmellsBad, "Cannot display #{subject}, there is no #display method and it is not a collection"
  end

  subject.display(options)
end