Module: CdnjsCommand::Helpers
- Included in:
- Fetcher
- Defined in:
- lib/cdnjs_command/helpers.rb
Instance Method Summary collapse
- #get_package(id) ⇒ Object
- #invalid_usage(usage = "cdnjs --help") ⇒ Object
- #show_help ⇒ Object
- #tip(message) ⇒ Object
Instance Method Details
#get_package(id) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/cdnjs_command/helpers.rb', line 12 def get_package(id) Package[id] or begin tip "Package not found." tip "For a list of all packages, see: cdnjs list" exit end end |
#invalid_usage(usage = "cdnjs --help") ⇒ Object
6 7 8 9 10 |
# File 'lib/cdnjs_command/helpers.rb', line 6 def invalid_usage(usage="cdnjs --help") puts "Invalid usage." puts "Try: #{usage.gsub(/^cdnjs/, File.basename($0))}" exit end |
#show_help ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cdnjs_command/helpers.rb', line 20 def show_help tip "Usage:" tip " cdnjs NAME - Download specific package" tip "" tip "Other commands:" tip " cdnjs list - List available packages" tip " cdnjs info NAME - Show package info" tip " cdnjs html NAME - Show HTML snippet to include given package" tip " cdnjs url NAME - Show the URL for the given package" tip " cdnjs update - Updates the package cache" tip "" tip "You may also use the first letters of each command; e.g., `cdnjs i jquery`." tip "Here are some common examples:" tip "" tip " $ cdnjs jquery" tip " $ echo `cdnjs h underscore` >> index.html" tip "" end |
#tip(message) ⇒ Object
2 3 4 |
# File 'lib/cdnjs_command/helpers.rb', line 2 def tip() $stderr.write "#{message}\n" end |