module Netfira::InstallerGenerator::Cli

Public Class Methods

main() click to toggle source
# File lib/netfira/installer_generator/cli.rb, line 8
def main

  generator = InstallerGenerator.new
  generator.output_device = :stdout

  option_parser = OptionParser.new do |opts|

    opts.separator "\nInput/Output"

    opts.on('-s', '--source [PATH]', 'Source EXE file') { |path| generator.source = path }
    opts.on('-t', '--target [PATH]', 'The EXE file to write') { |path| generator.target = path }
    opts.on('-i', '--icon [PATH]', 'The icon file to use for the generated installer') { |path| generator.icon = path }

    opts.separator "\nSigning"

    opts.on('-c', '--cert [PATH]', 'Signing certificate path') { |path| generator.signing_cert = path }
    opts.on('-k', '--key [PATH]', 'Signing certificate private key path') { |path| generator.signing_key = path }
    opts.on('-d', '--desc [TEXT]', 'Signing description') { |text| generator.signing_description = text }
    opts.on('-r', '--url [URL]', 'Signing URL') { |url| generator.signing_url = url }

    opts.separator "\nConfiguration"

    opts.on('-n', '--name [TEXT]', 'Installer name') { |text| generator.installer_name = text }
    opts.on('-x', '--temp-file [NAME]', 'Temporary installer filename') { |name| generator.installer_filename = name }
    opts.on('-u', '--shop-id [VALUE]', 'Shop ID') { |id| generator.shop_id = id }
    opts.on('-f', '--shop-url [URL]', 'Shop URL') { |url| generator.shop_url = url }
    opts.on('-b', '--sync-url [URL]', 'Sync URL') { |url| generator.sync_url = url }
    opts.on('-a', '--auth-server [URL]', 'Authentication server') { |url| generator.auth_server = url }
    opts.on('-e', '--temp-dir [DIR]', 'Temporary installation directory') { |dir| generator.temp_dir = dir }

  end

  begin
    option_parser.parse!
    generator.generate!
    puts "Wrote #{generator.target}"
  rescue => exception
    puts "#{exception.message}\n\n#{option_parser}"
  end

end