Class: Pocketbook::CLI::Runner
- Inherits:
-
Object
- Object
- Pocketbook::CLI::Runner
- Defined in:
- lib/pocketbook/cli/runner.rb
Defined Under Namespace
Classes: GitHubThemeSource
Instance Method Summary collapse
-
#initialize(stdout: $stdout, stderr: $stderr, options_parser: nil, watcher_class: Watcher) ⇒ Runner
constructor
A new instance of Runner.
- #run(argv = ARGV) ⇒ Object
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr, options_parser: nil, watcher_class: Watcher) ⇒ Runner
Returns a new instance of Runner.
39 40 41 42 43 44 |
# File 'lib/pocketbook/cli/runner.rb', line 39 def initialize(stdout: $stdout, stderr: $stderr, options_parser: nil, watcher_class: Watcher) @stdout = stdout @stderr = stderr @options_parser = || OptionsParser.new(stdout: @stdout) @watcher_class = watcher_class end |
Instance Method Details
#run(argv = ARGV) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pocketbook/cli/runner.rb', line 46 def run(argv = ARGV) command, request, parse_status = @options_parser.parse(argv) return if parse_status == :exit case command when :build run_build_command(request) when :watch build_watcher(request).run when :theme_new scaffold_theme(request) when :theme_validate validate_theme(request) when :theme_inspect inspect_theme(request) when :theme_get get_theme(request) else raise OptionParser::InvalidArgument, "Unknown command '#{command}'" end rescue OptionParser::ParseError, ArgumentError => e @stderr.puts("Error: #{e.}") @stderr.puts("Run with --help for usage.") exit(1) end |