Class: Skylab::Myterm::Cli

Inherits:
Face::Cli show all
Includes:
PathPrettifier
Defined in:
lib/myterm/cli.rb

Constant Summary collapse

DEFAULT_FONT_FILE =
"#{ENV['HOME']}/.fonts/MytermDefaultFont.ttf"
IMG_DIRNAME =
'/tmp'
IMG_BASENAME =
'iTermBG'

Constants included from PathPrettifier

PathPrettifier::HOME_DIR_RE

Constants inherited from Face::Cli

Face::Cli::Face

Constants included from Face::Command::Treeish

Face::Command::Treeish::Indent

Constants included from Face::Colors

Face::Colors::Esc, Face::Colors::Styles

Instance Attribute Summary

Attributes inherited from Face::Cli

#err, #out

Instance Method Summary collapse

Methods included from PathPrettifier

#pretty_path

Methods inherited from Face::Cli

#argument_error, #initialize, #program_name, #run, #version, version

Methods included from Face::Command::TreeDefiner

#command_definitions, #command_tree, #inherited, #method_added, #namespace, #on, #option_definitions, #option_parser

Methods included from Face::Command::Treeish

[], #ambiguous_command, #command_tree, #expecting, #find_command, #help, #option_parser, #run_opts, #unrecognized_command, #usage_string

Methods included from Face::Command::Nodeish

#build_empty_option_parser, #invite, #invocation_string, #parent=, #usage

Methods included from Face::Colors

#bold, #hi, #highlight_header, #ohno, #style, #yelo

Constructor Details

This class inherits a constructor from Skylab::Face::Cli

Instance Method Details

#bg(req, *args) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/myterm/cli.rb', line 65

def bg req, *args
  if args.empty?
    if req[:_exec_this]
      args.any? and fail("logic error -- see before_parse_bg.")
      args = req[:_exec_this]
    else
      return get_background
    end
  end
  check_font(req) or return
  img = ImageBuilder.build_background_image(iterm, args, req) or return false
  req[:verbose] and @err.puts "(bg_color: #{img.background_color.inspect})"
  outpath = "#{IMG_DIRNAME}/#{IMG_BASENAME}.#{Process.pid}.png"
  img.write(outpath)
  req[:verbose] and @err.puts "(setting background image to: #{outpath})" # doesn't care if --verbose
  iterm.session.background_image_path = outpath
  if req[:_exec_this]
    @err.puts "(#{program_name} executing: #{req[:_exec_this].join(' ')})"
    exec(req[:_exec_this].join(' '))
  end
  true
end

#bounds(o, *a) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/myterm/cli.rb', line 28

def bounds o, *a
  case a.length
  when 4
    begin ; iterm.bounds = a ; rescue ValidationError => e ; return usage e ; end
  when 0
    @err.puts iterm.bounds.inspect
  else
    return usage("bad number of args #{a.length}: expecting 0 or 4")
  end
end