class Teamocil::CLI

Constants

DIRECTORY

Public Instance Methods

run!() click to toggle source
# File lib/teamocil/cli.rb, line 5
def run!
  Teamocil.parse_options!(arguments: arguments)

  # List available layouts
  return Teamocil::Layout.print_available_layouts(directory: root) if Teamocil.options[:list]

  # Fetch the Layout object
  layout = Teamocil::Layout.new(path: layout_file_path)

  # Open layout file in $EDITOR
  return layout.edit! if Teamocil.options[:edit]

  # Output the layout raw content
  return layout.show! if Teamocil.options[:show]

  # Nothing? Let’s execute this layout!
  layout.execute!
end

Private Instance Methods

layout_file_path() click to toggle source
# File lib/teamocil/cli.rb, line 30
def layout_file_path
  if layout = Teamocil.options[:layout]
    layout
  else
    File.join(root, "#{arguments.first}.yml")
  end
end
root() click to toggle source
# File lib/teamocil/cli.rb, line 26
def root
  DIRECTORY.sub('$HOME', environment['HOME'])
end