Class: Bookflow::CLI
- Inherits:
-
Object
- Object
- Bookflow::CLI
- Defined in:
- lib/bookflow/cli.rb
Instance Method Summary collapse
-
#initialize(stdout: $stdout, stderr: $stderr, env: ENV, pwd: Dir.pwd) ⇒ CLI
constructor
A new instance of CLI.
- #run(argv) ⇒ Object
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr, env: ENV, pwd: Dir.pwd) ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 11 12 |
# File 'lib/bookflow/cli.rb', line 7 def initialize(stdout: $stdout, stderr: $stderr, env: ENV, pwd: Dir.pwd) @stdout = stdout @stderr = stderr @env = env @pwd = pwd end |
Instance Method Details
#run(argv) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bookflow/cli.rb', line 14 def run(argv) command = argv.shift unless command == "export" return write_error("Usage: bookflow export apple-books [options]") end source = argv.shift unless source == "apple-books" return write_error("Usage: bookflow export apple-books [options]") end = (argv) raise ArgumentError, "Unexpected arguments: #{argv.join(' ')}" unless argv.empty? export_apple_books() 0 rescue OptionParser::ParseError, ArgumentError => e write_error(e.) end |