Class: Gitdig::Command
- Inherits:
-
Object
- Object
- Gitdig::Command
- Extended by:
- Forwardable
- Defined in:
- lib/gitdig/command.rb
Direct Known Subclasses
Gitdig::Commands::Config::Org, Gitdig::Commands::Config::Token, Gitdig::Commands::Pr::Team
Constant Summary collapse
- CONFIG_FILE =
'.gitdig'
Instance Method Summary collapse
-
#command(**options) ⇒ Object
The external commands runner.
-
#configs ⇒ Object
Config for the tool.
-
#cursor ⇒ Object
The cursor movement.
-
#editor ⇒ Object
Open a file or text in the user’s preferred editor.
-
#exec_exist?(*args) ⇒ Boolean
Check if executable exists.
-
#execute ⇒ Object
Execute this command.
-
#generator ⇒ Object
File manipulation utility methods.
-
#github_client ⇒ Object
Octokit client for Github.
-
#pager(**options) ⇒ Object
Terminal output paging.
-
#platform ⇒ Object
Terminal platform and OS properties.
-
#prompt(**options) ⇒ Object
The interactive prompt.
-
#screen ⇒ Object
Get terminal screen properties.
-
#which(*args) ⇒ Object
The unix which utility.
Instance Method Details
#command(**options) ⇒ Object
The external commands runner
28 29 30 31 |
# File 'lib/gitdig/command.rb', line 28 def command(**) require 'tty-command' TTY::Command.new() end |
#configs ⇒ Object
Config for the tool
124 125 126 127 128 129 130 131 132 |
# File 'lib/gitdig/command.rb', line 124 def configs require 'tty-config' @configs ||= TTY::Config.new.tap do |c| c.filename = CONFIG_FILE c.append_path Dir.pwd c.append_path Dir.home c.read end end |
#cursor ⇒ Object
The cursor movement
38 39 40 41 |
# File 'lib/gitdig/command.rb', line 38 def cursor require 'tty-cursor' TTY::Cursor end |
#editor ⇒ Object
Open a file or text in the user’s preferred editor
48 49 50 51 |
# File 'lib/gitdig/command.rb', line 48 def editor require 'tty-editor' TTY::Editor end |
#exec_exist?(*args) ⇒ Boolean
Check if executable exists
118 119 120 121 |
# File 'lib/gitdig/command.rb', line 118 def exec_exist?(*args) require 'tty-which' TTY::Which.exist?(*args) end |
#execute ⇒ Object
Execute this command
16 17 18 19 20 21 |
# File 'lib/gitdig/command.rb', line 16 def execute(*) raise( NotImplementedError, "#{self.class}##{__method__} must be implemented" ) end |
#generator ⇒ Object
File manipulation utility methods
58 59 60 61 |
# File 'lib/gitdig/command.rb', line 58 def generator require 'tty-file' TTY::File end |
#github_client ⇒ Object
Octokit client for Github
135 136 137 138 139 140 |
# File 'lib/gitdig/command.rb', line 135 def github_client require 'octokit' @github_client ||= Octokit::Client.new( access_token: configs.fetch(:token) ) end |
#pager(**options) ⇒ Object
Terminal output paging
68 69 70 71 |
# File 'lib/gitdig/command.rb', line 68 def pager(**) require 'tty-pager' TTY::Pager.new() end |
#platform ⇒ Object
Terminal platform and OS properties
78 79 80 81 |
# File 'lib/gitdig/command.rb', line 78 def platform require 'tty-platform' TTY::Platform.new end |
#prompt(**options) ⇒ Object
The interactive prompt
88 89 90 91 |
# File 'lib/gitdig/command.rb', line 88 def prompt(**) require 'tty-prompt' TTY::Prompt.new() end |
#screen ⇒ Object
Get terminal screen properties
98 99 100 101 |
# File 'lib/gitdig/command.rb', line 98 def screen require 'tty-screen' TTY::Screen end |
#which(*args) ⇒ Object
The unix which utility
108 109 110 111 |
# File 'lib/gitdig/command.rb', line 108 def which(*args) require 'tty-which' TTY::Which.which(*args) end |