Class: Gitdig::Command

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gitdig/command.rb

Constant Summary collapse

CONFIG_FILE =
'.gitdig'

Instance Method Summary collapse

Instance Method Details

#command(**options) ⇒ Object

The external commands runner



28
29
30
31
# File 'lib/gitdig/command.rb', line 28

def command(**options)
  require 'tty-command'
  TTY::Command.new(options)
end

#configsObject

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

#cursorObject

The cursor movement



38
39
40
41
# File 'lib/gitdig/command.rb', line 38

def cursor
  require 'tty-cursor'
  TTY::Cursor
end

#editorObject

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

Returns:

  • (Boolean)

See Also:



118
119
120
121
# File 'lib/gitdig/command.rb', line 118

def exec_exist?(*args)
  require 'tty-which'
  TTY::Which.exist?(*args)
end

#executeObject

Execute this command

Raises:

  • (NotImplementedError)


16
17
18
19
20
21
# File 'lib/gitdig/command.rb', line 16

def execute(*)
  raise(
    NotImplementedError,
    "#{self.class}##{__method__} must be implemented"
  )
end

#generatorObject

File manipulation utility methods



58
59
60
61
# File 'lib/gitdig/command.rb', line 58

def generator
  require 'tty-file'
  TTY::File
end

#github_clientObject

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(**options)
  require 'tty-pager'
  TTY::Pager.new(options)
end

#platformObject

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(**options)
  require 'tty-prompt'
  TTY::Prompt.new(options)
end

#screenObject

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