Class: WinToaster::CLI
- Inherits:
-
Object
- Object
- WinToaster::CLI
- Defined in:
- lib/win_toaster/cli.rb
Overview
Command-line front-end for win_toaster.
win_toaster TITLE MESSAGE [--detail DETAIL] [--app-id APP_ID]
Class Method Summary collapse
-
.run(argv) ⇒ Object
Runs the CLI and returns the process exit code.
Instance Method Summary collapse
Class Method Details
.run(argv) ⇒ Object
Runs the CLI and returns the process exit code.
12 13 14 |
# File 'lib/win_toaster/cli.rb', line 12 def self.run(argv) new.run(argv) end |
Instance Method Details
#run(argv) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/win_toaster/cli.rb', line 16 def run(argv) = { detail: nil, image: nil, hero: nil, app_id: Notifier::DEFAULT_APP_ID } parser = OptionParser.new do |o| o. = "Usage: win_toaster TITLE MESSAGE [options]" o.on("-d", "--detail DETAIL", "Third line shown below the message") { |v| [:detail] = v } o.on("-i", "--image PATH", "Icon image (appLogoOverride)") { |v| [:image] = v } o.on("--hero PATH", "Hero (large banner) image") { |v| [:hero] = v } o.on("-a", "--app-id APP_ID", "AppUserModelId the toast is shown under") { |v| [:app_id] = v } o.on("-v", "--version", "Show version and exit") do puts WinToaster::VERSION return 0 end o.on("-h", "--help", "Show this help and exit") do puts o return 0 end end title, = parser.parse(argv) if title.nil? || .nil? warn parser. return 1 end WinToaster.notify( title: title, message: , detail: [:detail], image: [:image], hero: [:hero], app_id: [:app_id] ) 0 rescue OptionParser::ParseError, WinToaster::Error => e warn "win_toaster: #{e.}" 1 end |