Class: Cheatly::CLI
Instance Method Summary collapse
- #create(handle) ⇒ Object
- #edit(handle) ⇒ Object
- #help ⇒ Object
- #list ⇒ Object
- #show(handle) ⇒ Object
- #version ⇒ Object
Instance Method Details
#create(handle) ⇒ Object
44 45 46 47 48 |
# File 'lib/cheatly/cli.rb', line 44 def create(handle) sheet = LocalSheet.new(handle) sheet.body = write_to_tempfile(handle) sheet.save end |
#edit(handle) ⇒ Object
51 52 53 54 55 |
# File 'lib/cheatly/cli.rb', line 51 def edit(handle) sheet = LocalSheet.find(handle) sheet.body = write_to_tempfile(handle, sheet.body) sheet.save end |
#help ⇒ Object
58 59 60 |
# File 'lib/cheatly/cli.rb', line 58 def help show('help') end |
#list ⇒ Object
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 |