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
42 43 44 45 46 |
# File 'lib/cheatly/cli.rb', line 42 def create(handle) sheet = Sheet.with_file_adapter.new(handle) sheet.body = write_to_tempfile(handle) sheet.save end |
#edit(handle) ⇒ Object
49 50 51 52 53 |
# File 'lib/cheatly/cli.rb', line 49 def edit(handle) sheet = Sheet.with_file_adapter.find(handle) sheet.body = write_to_tempfile(handle, sheet.body) sheet.save end |
#help ⇒ Object
56 57 58 |
# File 'lib/cheatly/cli.rb', line 56 def help show('help') end |
#list ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/cheatly/cli.rb', line 32 def list sheets = model.all page puts "List of available cheat-sheets:" sheets.each do |sheet| puts " #{sheet.title}" end end |
#show(handle) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cheatly/cli.rb', line 19 def show(handle) sheet = model.find(handle) unless sheet puts "Sheet not found, run 'cheatly list' to see the availables." return end page renderer = Renderer.new md = Redcarpet::Markdown.new(renderer, no_intra_emphasis: true) puts md.render(sheet.to_s) end |