Class: Dri::Command
- Inherits:
-
Object
- Object
- Dri::Command
- Extended by:
- Forwardable
- Includes:
- Utils::Helpers
- Defined in:
- lib/dri/command.rb
Direct Known Subclasses
Dri::Commands::Add::FastQuarantine, Dri::Commands::Analyze::StackTraces, Dri::Commands::FAQ, Dri::Commands::Fetch::Failures, Dri::Commands::Fetch::FeatureFlags, Dri::Commands::Fetch::Pipelines, Dri::Commands::Fetch::Runbooks, Dri::Commands::Fetch::Testcases, Dri::Commands::Fetch::Triaged, Dri::Commands::Incidents, Dri::Commands::Init, Dri::Commands::Profile, Dri::Commands::Publish::Report, Dri::Commands::Rm::Emoji, Dri::Commands::Rm::Profile, Dri::Commands::Rm::Reports, Dri::Commands::View::FastQuarantine
Instance Method Summary collapse
- #add_color(str, *color) ⇒ Object
- #api_client(ops: false) ⇒ Object
- #bold(str) ⇒ 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.
-
#initialize(*options) ⇒ Command
constructor
A new instance of Command.
- #pastel(**options) ⇒ Object
-
#prompt(**options) ⇒ Object
The interactive prompt.
- #spinner ⇒ Object
- #verify_config_exists ⇒ Object
Methods included from Utils::Helpers
Constructor Details
#initialize(*options) ⇒ Command
Returns a new instance of Command.
23 24 25 |
# File 'lib/dri/command.rb', line 23 def initialize(*) @options = end |
Instance Method Details
#add_color(str, *color) ⇒ Object
42 43 44 |
# File 'lib/dri/command.rb', line 42 def add_color(str, *color) @options[:no_color] ? str : pastel.decorate(str, *color) end |
#api_client(ops: false) ⇒ Object
31 32 33 |
# File 'lib/dri/command.rb', line 31 def api_client(ops: false) ApiClient.new(config, ops) end |
#bold(str) ⇒ Object
46 47 48 |
# File 'lib/dri/command.rb', line 46 def bold(str) pastel.bold(str) end |
#command(**options) ⇒ Object
The external commands runner
70 71 72 73 |
# File 'lib/dri/command.rb', line 70 def command(**) require 'tty-command' TTY::Command.new(**) end |
#cursor ⇒ Object
The cursor movement
80 81 82 83 |
# File 'lib/dri/command.rb', line 80 def cursor require 'tty-cursor' TTY::Cursor end |
#editor ⇒ Object
Open a file or text in the user’s preferred editor
90 91 92 93 |
# File 'lib/dri/command.rb', line 90 def editor require 'tty-editor' TTY::Editor end |
#execute ⇒ Object
Execute this command
53 54 55 56 57 58 |
# File 'lib/dri/command.rb', line 53 def execute(*) raise( NotImplementedError, "#{self.class}##{__method__} must be implemented" ) end |
#pastel(**options) ⇒ Object
27 28 29 |
# File 'lib/dri/command.rb', line 27 def pastel(**) Pastel.new(**) end |
#prompt(**options) ⇒ Object
The interactive prompt
100 101 102 103 |
# File 'lib/dri/command.rb', line 100 def prompt(**) require 'tty-prompt' TTY::Prompt.new(**.merge(interrupt: :exit)) end |
#spinner ⇒ Object
60 61 62 63 |
# File 'lib/dri/command.rb', line 60 def spinner require 'tty-spinner' TTY::Spinner.new("[:spinner] ⏳", format: :classic) end |
#verify_config_exists ⇒ Object
35 36 37 38 39 40 |
# File 'lib/dri/command.rb', line 35 def verify_config_exists return if config.exist? logger.error "Oops, could not find a configuration. Try using #{add_color('dri init', :yellow)} first." exit 1 end |