Class: Devlogs::CLI
- Inherits:
-
Thor
- Object
- Thor
- Devlogs::CLI
- Includes:
- TTYPromptHelper
- Defined in:
- lib/devlogs/cli.rb
Overview
The CLI devlogs CLI
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
Returns exit with non zero status when an exception occurs.
Instance Method Summary collapse
- #init ⇒ Object
- #last ⇒ Object
- #ls ⇒ Object
- #ls_issues ⇒ Object
- #new ⇒ Object
- #new_issue ⇒ Object
- #version ⇒ Object
Methods included from TTYPromptHelper
Class Method Details
.exit_on_failure? ⇒ Boolean
Returns exit with non zero status when an exception occurs
21 22 23 |
# File 'lib/devlogs/cli.rb', line 21 def self.exit_on_failure? true end |
Instance Method Details
#init ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/devlogs/cli.rb', line 39 def init puts "Creating devlogs repository" Repository::Initializer.run( { force: .force?, dirpath: .dirpath } ) puts "Created devlogs repository" end |
#last ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/devlogs/cli.rb', line 57 def last puts "Reading last entry" last_entry = repo.ls.first if .open? Editor.open(last_entry) else puts File.read(last_entry) end end |
#ls ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/devlogs/cli.rb', line 118 def ls entries = repo.ls if entries.empty? puts "No logs present in this repository" exit 0 end # Use the file names as visible keys for the prompt entry_names = entries.map { |e| File.basename(e) } # Build the TTY:Prompt result = build_select_prompt(data: entry_names, text: "Select a log entry...") # Open in paging program Pager.open(entries[result]) end |
#ls_issues ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/devlogs/cli.rb', line 96 def ls_issues issues = repo.ls_issues if issues.empty? puts "No issues present in this repository" exit 0 end # Use the file names as visible keys for the prompt issue_names = issues.map { |e| File.basename(e) } # Build the TTY:Prompt result = build_select_prompt(data: issue_names, text: "Select an issue issue...") # Open in paging program Pager.open(issues[result]) end |
#new ⇒ Object
74 75 76 77 78 79 |
# File 'lib/devlogs/cli.rb', line 74 def new puts "Creating new entry..." repo.create repo.sync end |
#new_issue ⇒ Object
87 88 89 90 |
# File 'lib/devlogs/cli.rb', line 87 def new_issue repo.create_issue repo.sync end |