Method: RunLoop::PlistBuddy#run_command

Defined in:
lib/run_loop/plist_buddy.rb

#run_command(cmd, file, opts = {}) ⇒ Object

Sends an arbitrary command (-c) to PlistBuddy.

This class does not handle setting data, date, dictionary, or array or manipulating elements in existing array or dictionary types. This method is an attempt to bridge this gap.

When setting/adding bool, real, integer, string values, use #plist_set.

For reading values, use #plist_read.

Parameters:

  • cmd (String)

    The command passed to PlistBuddy with -c

  • file (String)

    Path the plist file

  • opts (Hash) (defaults to: {})

    options for controlling execution

Options Hash (opts):

  • :verbose (Boolean) — default: false

    controls log level

Returns:

  • Boolean, String Success and the output of running the command.

Raises:

  • RuntimeError when running the command fails.



130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/run_loop/plist_buddy.rb', line 130

def run_command(cmd, file, opts={})
  success, output = execute_plist_cmd(cmd, file, opts)
  if !success
    raise RuntimeError, %Q[
Encountered an error performing operation on plist:

#{plist_buddy} -c "#{cmd}" #{file}
=> #{output}
]
  end
  return success, output
end