Sha256: 517eb708cf1c891ab21c7bb43165c948752c825f3dbdb51b6b269938e57a34ad
Contents?: true
Size: 1.31 KB
Versions: 14
Compression:
Stored size: 1.31 KB
Contents
#!/usr/bin/env ruby require 'optparse' require 'terminal-table' require 'magento_remote' require 'bin_helper' # Sweet, sweet options. options = {} program_name = File.basename __FILE__ optparse = OptionParser.new do |opts| opts.banner = "Usage: #{program_name} [OPTIONS]\n Show last order." opts.separator "" MagentoRemote::CLI::Options::add_shop_options opts, options opts.separator "" opts.separator "Output options" opts.on('-d', '--debug FILE', 'enable debugging output, STDOUT, or FILE if given') do |d| if d options[:debug] = d else options[:debug] = true end end opts.separator "" opts.separator "General options" opts.on_tail('--version', 'Show version.') do puts "magento_list_order #{MagentoRemote::VERSION}" exit 0 end opts.on('-h', '--help', 'Show help.') do puts opts exit 0 end end optparse.parse! # Exit if not all obligatory params given. MagentoRemote::CLI::Options::exit_obligatory! options mech = MagentoMech.from_config options if options[:debug] == true mech.log_to! STDOUT elsif options[:debug] mech.log_to! options[:debug] end return_code = 0 mech.login orders = mech.last_orders if orders.empty? puts "Nothing found" else puts Terminal::Table.new :headings => ['Date', 'Volume', 'link'], :rows => orders end exit return_code
Version data entries
14 entries across 14 versions & 1 rubygems