Class: Repofetch::CLI
- Inherits:
-
Object
- Object
- Repofetch::CLI
- Defined in:
- lib/repofetch/cli.rb
Overview
Command line interface for repofetch.
Instance Attribute Summary collapse
-
#plugin ⇒ Object
readonly
Returns the value of attribute plugin.
-
#repository_path ⇒ Object
readonly
Returns the value of attribute repository_path.
Instance Method Summary collapse
- #define_options ⇒ Object
-
#initialize(config = nil, args = ARGV) ⇒ CLI
constructor
Define the command line interface.
- #load_plugins ⇒ Object
- #new_plugin ⇒ Object
-
#start ⇒ Integer
Run the command line interface.
Constructor Details
Instance Attribute Details
#plugin ⇒ Object (readonly)
Returns the value of attribute plugin.
12 13 14 |
# File 'lib/repofetch/cli.rb', line 12 def plugin @plugin end |
#repository_path ⇒ Object (readonly)
Returns the value of attribute repository_path.
12 13 14 |
# File 'lib/repofetch/cli.rb', line 12 def repository_path @repository_path end |
Instance Method Details
#define_options ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/repofetch/cli.rb', line 36 def OptionParser.new do |opts| opts. = 'Usage: repofetch [options] -- [plugin arguments]' (opts) (opts) add_version_option(opts) (opts) end end |
#load_plugins ⇒ Object
47 48 49 |
# File 'lib/repofetch/cli.rb', line 47 def load_plugins @config.plugins.each { |plugin| require plugin } end |
#new_plugin ⇒ Object
51 52 53 54 55 |
# File 'lib/repofetch/cli.rb', line 51 def new_plugin return @plugin.from_args(@args) unless @plugin.nil? Repofetch.get_plugin(@repository_path, @args) end |
#start ⇒ Integer
Run the command line interface.
27 28 29 30 31 32 33 34 |
# File 'lib/repofetch/cli.rb', line 27 def start load_plugins .parse!(@args) return @exit unless @exit.nil? start_plugin end |