Class: Teems::Commands::Org

Inherits:
Base
  • Object
show all
Includes:
OrgRenderer, OrgTreeWalker
Defined in:
lib/teems/commands/org.rb

Overview

Show org chart for a user

Constant Summary collapse

ORG_OPTIONS =
{
  '--depth' => ->(opts, args) { opts[:depth] = parse_depth(args.shift) }
}.freeze

Instance Attribute Summary

Attributes inherited from Base

#options, #positional_args, #runner

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, runner:) ⇒ Org

Returns a new instance of Org.



141
142
143
144
# File 'lib/teems/commands/org.rb', line 141

def initialize(args, runner:)
  @options = {}
  super
end

Class Method Details

.parse_depth(value) ⇒ Object



134
135
136
137
138
139
# File 'lib/teems/commands/org.rb', line 134

def self.parse_depth(value)
  return 1 unless value

  result = value.to_i
  result >= 0 ? result : 1
end

Instance Method Details

#executeObject



146
147
148
149
150
151
152
153
154
# File 'lib/teems/commands/org.rb', line 146

def execute
  result = validate_options
  return result if result

  auth_result = require_auth
  return auth_result if auth_result

  show_org_chart
end