Class: Haml::I18n::Extractor::CLI
- Inherits:
-
Object
- Object
- Haml::I18n::Extractor::CLI
- Defined in:
- lib/haml-i18n-extractor/flow/cli.rb
Defined Under Namespace
Classes: CliError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ CLI
constructor
A new instance of CLI.
- #start ⇒ Object
Constructor Details
#initialize(opts) ⇒ CLI
Returns a new instance of CLI.
6 7 8 9 |
# File 'lib/haml-i18n-extractor/flow/cli.rb', line 6 def initialize(opts) = opts || {} @prompter = Haml::I18n::Extractor::Prompter.new # may as well end |
Class Method Details
.option_parser ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/haml-i18n-extractor/flow/cli.rb', line 11 def self.option_parser option_parser = Trollop::Parser.new do "\nhaml-i18n-extractor --version # print version of this gem\nhaml-i18n-extractor --help # this message\nhaml-i18n-extractor <path> [--interactive|--non-interactive] [--other-options]\n\nSee options list (short options available next to long option):\\n\n\n" version "Current version: #{Haml::I18n::Extractor::VERSION}" opt :interactive, "interactive mode", :short => 'i' opt :non_interactive, "non interactive mode", :short => 'n' opt :yaml_file, "yaml file path, defaults to config/locales/en.yml", :type => String, :short => 'y' opt :i18n_scope, "top level i18n scope, defaults to :en", :type => String, :short => 's' end end |
.show_help! ⇒ Object
30 31 32 33 34 |
# File 'lib/haml-i18n-extractor/flow/cli.rb', line 30 def self.show_help! Trollop::with_standard_exception_handling option_parser do raise Trollop::HelpNeeded end end |
Instance Method Details
#start ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/haml-i18n-extractor/flow/cli.rb', line 36 def start check_interactive_or_not_passed if [:path] check_interactive_or_not_passed pth = File.([:path]) if File.directory?(pth) workflow = Haml::I18n::Extractor::Workflow.new(pth, ) workflow.run elsif File.exists?(pth) .merge!(:type => :overwrite) extractor = Haml::I18n::Extractor.new(pth, ) extractor.run end end end |