#!/usr/bin/env ruby $:.unshift File.join(File.dirname(__FILE__), "..", "lib") #require "byebug" require "roku_builder" require "optparse" require "pathname" options = {} options[:config] = '~/.roku_config.json' options[:stage] = 'production' options[:update_manifest] = false options[:fetch] = false OptionParser.new do |opts| opts.banner = "Usage: roku [options]" opts.on("-l", "--sideload", "Command: Sideload an app") do |s| options[:sideload] = s end opts.on("-p", "--package", "Command: Package an app") do |p| options[:package] = p end opts.on("-t", "--test", "Command: Test an app") do |t| options[:test] = t end opts.on("-L", "--deeplink", "Command: Deeplink into app. Requires mgid and type options.") do |d| options[:deeplink] = d end opts.on("--configure", "Command: Copy base configuration file to the --config location. Default: '~/.roku_config.json'") do |c| options[:configure] = c end opts.on("--validate", "Command: Validate configuration'") do |v| options[:validate] = v end opts.on("-d", "--delete", "Command: Delete the currently sideloaded app") do |d| options[:delete] = d end opts.on("-N", "--navigate CMD", "Command: send the given command to the roku") do |n| options[:navigate] = n end opts.on("-S", "--screencapture", "Command: save a screencapture to the output file/folder") do |s| options[:screencapture] = s end opts.on("-y", "--type TEXT", "Command: type the given text on the roku device") do |t| options[:text] = t end opts.on("-b", "--build", "Command: build a zip to be sideloaded") do |b| options[:build] = b end opts.on("--screen SCREEN", "Command: show a screen") do |s| options[:screen] = s end opts.on("--screens", "Command: show possible screens") do |s| options[:screens] = s end opts.on("-m", "--monitor TYPE", "Command: run telnet to monitor roku log") do |m| options[:monitor] = m end opts.on("-u", "--update-manifest", "Command: update the manifest file") do |u| options[:update] = u end opts.on("-r", "--ref REF", "Git referance to use for sideloading") do |r| options[:ref] = r end opts.on("-w", "--working", "Use working directory to sideload or test") do |w| options[:working] = w end opts.on("-c", "--current", "Use current directory to sideload or test. Overides any project config") do |w| options[:current] = true end opts.on("-s", "--stage STAGE", "Set the stage to use. Default: 'production'") do |b| options[:stage] = b options[:set_stage] = true end opts.on("-M", "--manifest-update", "Update the manifest file while packaging") do |n| options[:update_manifest] = true end opts.on("-i", "--inspect", "Print inspection information while packaging") do |n| options[:inspect] = true end opts.on("-f", "--fetch", "Preform a `git fetch --all` on the repository before building or sideloading.") do options[:fetch] = true end opts.on("-o", "--deeplink-options TYPE", "Additional deeplink options. (eg. a:b, c:d,e:f)") do |o| options[:deeplink_options] = o end opts.on("-e", "--edit PARAMS", "Edit config params when configuring. (eg. a:b, c:d,e:f)") do |p| options[:edit_params] = p end opts.on("--config CONFIG", "Set a custom config file. Default: '~/.roku_config.rb'") do |c| options[:config] = c end opts.on("-D", "--device ID", "Use a different device corresponding to the given ID") do |d| options[:device] = d options[:device_given] = true end opts.on("-P", "--project ID", "Use a different project") do |p| options[:project] = p end opts.on("-O", "--out PATH", "Output file/folder. If PATH ends in .pkg/.zip/.jpg, file is assumed, otherwise folder is assumed") do |o| options[:out] = o end opts.on("-V", "--verbose", "Print Info message") do |v| options[:verbose] = v end opts.on("--debug", "Print Debug messages") do |d| options[:debug] = d end opts.on("-h", "--help", "Show this message") do |h| puts opts exit end opts.on("-v", "--version", "Show version") do puts RokuBuilder::VERSION exit end end.parse! RokuBuilder::Controller.run(options: options)