BVB Source Codes

hologram Show cli.rb Source code

Return Download hologram: download cli.rb Source code - Download hologram Source code - Type:.rb
  1. require 'optparse'
  2.  
  3. module Hologram
  4.   class CLI
  5.     attr_reader :args
  6.  
  7.     def initialize(args)
  8.       @args = args
  9.     end
  10.  
  11.     def run
  12.       return setup if args[0] == 'init'
  13.       extra_args = []
  14.  
  15.       #support passing the config file with no command line flag
  16.       config = args[0].nil? ? 'hologram_config.yml' : args[0]
  17.  
  18.       OptionParser.new do |opt|
  19.         opt.on_tail('-h', '--help', 'Show this message.') { puts opt; exit }
  20.         opt.on_tail('-v', '--version', 'Show version.') { puts "hologram #{Hologram::VERSION}"; exit }
  21.         opt.on('-c', '--config FILE', 'Path to config file. Default: hologram_config.yml') { |config_file| config = config_file }
  22.         begin
  23.           opt.parse!(args)
  24.         rescue OptionParser::InvalidOption => e
  25.           extra_args.push(e.to_s.sub(/invalid option:\s+/, ''))
  26.         end
  27.  
  28.       end
  29.  
  30.       config.nil? ? build(extra_args) : build(extra_args, config)
  31.  
  32.     end
  33.  
  34.     private
  35.     def build(extra_args = [], config = 'hologram_config.yml')
  36.       builder = DocBuilder.from_yaml(config, extra_args)
  37.       DisplayMessage.error(builder.errors.first) if !builder.is_valid?
  38.       builder.build
  39.     rescue CommentLoadError, NoCategoryError => e
  40.       DisplayMessage.error(e.message)
  41.     rescue Errno::ENOENT
  42.       DisplayMessage.error("Could not load config file, try 'hologram init' to get started")
  43.     end
  44.  
  45.     def setup
  46.       DocBuilder.setup_dir
  47.     rescue => e
  48.       DisplayMessage.error("#{e}")
  49.     end
  50.   end
  51. end
  52.  
downloadcli.rb Source code - Download hologram Source code
Related Source Codes/Software:
www.html5rocks.com - ....a top-notch resource for web developer 2017-05-12
MTStatusBarOverlay - A custom iOS status bar overlay seen in Apps like ... 2017-05-12
blueprint - Reverse engineer server configuration ... 2017-05-12
PullToRefresh - A simple iPhone TableViewController for adding the... 2017-05-12
mrjob - Run MapReduce jobs on Hadoop or Amazon Web Service... 2017-05-11
isso - a Disqus alternative https:... 2017-05-12
python3-cookbook - "The Python Cookbook" 3 rd Edition Translatio 2017-05-12
TSA-Travel-Sentry-master-keys - 3D reproduction of TSA Master key 2017-05-12
fatfree - A powerful yet easy-to-use PHP micro-framework des... 2017-05-13
rolify - Role management library with the resource scoping 2017-05-13
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top