class NewlineHw::Cli
Public Instance Methods
config()
click to toggle source
# File lib/newline_hw/cli.rb, line 10 def config `#{NewlineHw.config.editor} #{NewlineHw::Config::CONFIG_PATH}` end
exit_on_failure?()
click to toggle source
# File lib/newline_hw/cli.rb, line 97 def exit_on_failure? true end
gui_trigger(id)
click to toggle source
# File lib/newline_hw/cli.rb, line 92 def gui_trigger(id) GuiTrigger.new({ id: id }, config).call end
init()
click to toggle source
# File lib/newline_hw/cli.rb, line 5 def init puts Shell::Function.cmd end
install()
click to toggle source
# File lib/newline_hw/cli.rb, line 16 def install NewlineHw::Config.install_default say "Installed a config file to `#{NewlineHw::Config::CONFIG_PATH}`" install_chrome_hook say "" say ("*" * 30) + " YOU MUST!! Add this line to your shell profile " + ("*" * 30), :red say '$ eval "$(newline_hw init)"' say ("*" * 30), :red end
install_chrome_hook()
click to toggle source
# File lib/newline_hw/cli.rb, line 34 def install_chrome_hook NewlineHw.make_log_directory begin ChromeManifest.write say "Chrome Native Messaging Hook installed for Newline Assistant", :green rescue Errno::EACCES => e path = "~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.theironyard.newlinecli.hw.json" say "Could NOT add chrome native messaging hook please check permissions for #{path} and that containing folder exists with 0600 permissions.", :red say "*" * 80 say "" say " sudo chown -R $(whoami) #{path} " say "" say "Error Message: #{e.message}" end end
run_command(working_dir, _submission_id = nil)
click to toggle source
# File lib/newline_hw/cli.rb, line 85 def run_command(working_dir, _submission_id = nil) puts Shell::Run.new(working_dir, config).cmd end
setup_command(submission_id)
click to toggle source
# File lib/newline_hw/cli.rb, line 67 def setup_command(submission_id) puts Shell::Setup.new(submission_id, config).cmd rescue NewlineHw::AuthenticationError => e say "Could not log into Newline using NewlineCLI, have you logged in?" say "Error from NewlineCli #{e.message}" exit 3 rescue Excon::Error::Socket => e say "Error could not open a connection to newline. Do you have internet?" say "Error message #{e.message}" exit 3 rescue Excon::Error::Forbidden => e say "You do not have access to this submission." say "Error message #{e.message}" exit 3 end
uninstall()
click to toggle source
# File lib/newline_hw/cli.rb, line 52 def uninstall NewlineHw.remove_log_directory say "Chrome Messaging Logs REMOVED", :green ChromeManifest.remove say "Chrome Native Messaging Hook REMOVED", :green say "Finish uninstall with these commands" say "" say " rm #{NewlineHw::Config::CONFIG_PATH}" say " gem uninstall newline_hw --executables" say "" end
upgrade()
click to toggle source
# File lib/newline_hw/cli.rb, line 27 def upgrade `gem install newline_hw && newline_hw install_chrome_hook` end