Class: HashcardsReadwise::CLI
- Inherits:
-
Object
- Object
- HashcardsReadwise::CLI
- Defined in:
- lib/hashcards_readwise/cli.rb
Instance Method Summary collapse
-
#initialize(args = ARGV) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(args = ARGV) ⇒ CLI
Returns a new instance of CLI.
8 9 10 11 12 |
# File 'lib/hashcards_readwise/cli.rb', line 8 def initialize(args = ARGV) @args = args @logger = Logger.new($stderr, level: Logger::WARN) @logger.progname = "hashcards-readwise" end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/hashcards_readwise/cli.rb', line 14 def run OptionParser.new do |o| o.on("-v", "--verbose", "Enable verbose logging (can be repeated)") { @logger.level -= 1 } end.order!(@args) command = @args.shift case command when "convert" run_convert when "push" run_push when "sync" run_sync when "version", "-v", "--version" puts "hashcards-readwise #{VERSION}" when "help", "-h", "--help", nil print_help else @logger.warn("Unknown command: #{command}") print_help exit 1 end end |