Class: Cheatly::CLI
Instance Method Summary collapse
- #create(handle) ⇒ Object
- #edit(handle) ⇒ Object
- #help ⇒ Object
- #list ⇒ Object (also: #ls)
- #show(handle) ⇒ Object
- #version ⇒ Object
Instance Method Details
#create(handle) ⇒ Object
47 48 49 50 51 |
# File 'lib/cheatly/cli.rb', line 47 def create(handle) sheet = LocalSheet.new(handle) sheet.body = write_to_tempfile(handle) sheet.save end |
#edit(handle) ⇒ Object
54 55 56 57 58 |
# File 'lib/cheatly/cli.rb', line 54 def edit(handle) sheet = LocalSheet.find(handle) sheet.body = write_to_tempfile(handle, sheet.body) sheet.save end |
#help ⇒ Object
61 62 63 |
# File 'lib/cheatly/cli.rb', line 61 def help show('help') end |
#list ⇒ Object Also known as: ls
34 35 36 37 38 39 40 41 |
# File 'lib/cheatly/cli.rb', line 34 def list sheets = model.all page unless [:nopaginate] puts "List of available cheat-sheets:" sheets.each do |sheet| puts " #{sheet.title}" end end |
#show(handle) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cheatly/cli.rb', line 21 def show(handle) sheet = model.find(handle) unless sheet puts "Sheet not found, run 'cheatly list' to see the availables." return end page unless [:nopaginate] renderer = Renderer.new md = Redcarpet::Markdown.new(renderer, no_intra_emphasis: true) puts md.render(sheet.to_s) end |
#version ⇒ Object
66 67 68 |
# File 'lib/cheatly/cli.rb', line 66 def version puts "Cheatly version #{Cheatly::VERSION}" end |