Class: Bebox::Cli

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/bebox/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#error, #highline_quest, #highline_warn, included, #info, #linebreak, #msg, #ok, #quest, #title, #warn

Constructor Details

#initialize(*args) ⇒ Cli

Returns a new instance of Cli.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bebox/cli.rb', line 8

def initialize(*args)
  # add the GLI magic on to the Bebox::Cli instance
  self.extend GLI::App

  program_desc 'Create basic provisioning of remote servers.'
  version Bebox::VERSION

  if inside_project?
    self.extend Bebox::ProjectCommands
  else
    self.extend Bebox::GeneralCommands
  end
  exit run(*args)
end

Instance Attribute Details

#project_rootObject

Returns the value of attribute project_root.



6
7
8
# File 'lib/bebox/cli.rb', line 6

def project_root
  @project_root
end

Instance Method Details

#inside_project?Boolean

Search recursively for .bebox file to see if current directory is a bebox project or not

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bebox/cli.rb', line 25

def inside_project?
  project_found = false
  cwd = Pathname(Dir.pwd)
  home_directory = File.expand_path('~')
  cwd.ascend do |current_path|
    project_found = File.file?("#{current_path.to_s}/.bebox")
    self.project_root = current_path.to_s if project_found
    break if project_found || (current_path.to_s == home_directory)
  end
  project_found
end