Class: Dri::Command
- Inherits:
-
Object
- Object
- Dri::Command
- Extended by:
- Forwardable
- Defined in:
- lib/dri/command.rb
Direct Known Subclasses
Dri::Commands::Fetch::Failures, Dri::Commands::Fetch::Testcases, Dri::Commands::Init, Dri::Commands::Profile, Dri::Commands::Publish::Report, Dri::Commands::Rm::Emoji
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Main configuration.
-
#emoji ⇒ Object
readonly
Returns the value of attribute emoji.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#timezone ⇒ Object
readonly
Returns the value of attribute timezone.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #add_color(str, *color) ⇒ Object
- #api_client ⇒ Object
-
#command(**options) ⇒ Object
The external commands runner.
-
#cursor ⇒ Object
The cursor movement.
-
#editor ⇒ Object
Open a file or text in the user’s preferred editor.
-
#execute ⇒ Object
Execute this command.
- #logger ⇒ Object
- #pastel(**options) ⇒ Object
-
#prompt(**options) ⇒ Object
The interactive prompt.
- #spinner ⇒ Object
- #verify_config_exists ⇒ Object
Instance Attribute Details
#config ⇒ Object (readonly)
Main configuration
21 22 23 |
# File 'lib/dri/command.rb', line 21 def config @config end |
#emoji ⇒ Object (readonly)
Returns the value of attribute emoji.
14 15 16 |
# File 'lib/dri/command.rb', line 14 def emoji @emoji end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
14 15 16 |
# File 'lib/dri/command.rb', line 14 def profile @profile end |
#timezone ⇒ Object (readonly)
Returns the value of attribute timezone.
14 15 16 |
# File 'lib/dri/command.rb', line 14 def timezone @timezone end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
14 15 16 |
# File 'lib/dri/command.rb', line 14 def token @token end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
14 15 16 |
# File 'lib/dri/command.rb', line 14 def username @username end |
Instance Method Details
#add_color(str, *color) ⇒ Object
63 64 65 |
# File 'lib/dri/command.rb', line 63 def add_color(str, *color) [:no_color] ? str : pastel.decorate(str, *color) end |
#api_client ⇒ Object
32 33 34 |
# File 'lib/dri/command.rb', line 32 def api_client ApiClient.new(config) end |
#command(**options) ⇒ Object
The external commands runner
92 93 94 95 |
# File 'lib/dri/command.rb', line 92 def command(**) require 'tty-command' TTY::Command.new() end |
#cursor ⇒ Object
The cursor movement
102 103 104 105 |
# File 'lib/dri/command.rb', line 102 def cursor require 'tty-cursor' TTY::Cursor end |
#editor ⇒ Object
Open a file or text in the user’s preferred editor
112 113 114 115 |
# File 'lib/dri/command.rb', line 112 def editor require 'tty-editor' TTY::Editor end |
#execute ⇒ Object
Execute this command
70 71 72 73 74 75 |
# File 'lib/dri/command.rb', line 70 def execute(*) raise( NotImplementedError, "#{self.class}##{__method__} must be implemented" ) end |
#logger ⇒ Object
77 78 79 80 |
# File 'lib/dri/command.rb', line 77 def logger require 'tty-logger' TTY::Logger.new end |
#pastel(**options) ⇒ Object
16 17 18 |
# File 'lib/dri/command.rb', line 16 def pastel(**) Pastel.new(**) end |
#prompt(**options) ⇒ Object
The interactive prompt
122 123 124 125 |
# File 'lib/dri/command.rb', line 122 def prompt(**) require 'tty-prompt' TTY::Prompt.new() end |
#spinner ⇒ Object
82 83 84 85 |
# File 'lib/dri/command.rb', line 82 def spinner require 'tty-spinner' TTY::Spinner.new("[:spinner] ⏳", format: :classic) end |
#verify_config_exists ⇒ Object
56 57 58 59 60 61 |
# File 'lib/dri/command.rb', line 56 def verify_config_exists if !config.exist? logger.error "Oops, could not find a configuration. Try using #{add_color('dri init', :yellow)} first." exit 1 end end |