Module: Prigner::CLI
- Defined in:
- lib/prigner/cli.rb
Overview
Command-Line Interface
This module look a command placed in CLI directory and run it.
Defined Under Namespace
Classes: Status
Class Method Summary collapse
-
.commands ⇒ Object
List of commands placed in
lib/prigner/cli/
. -
.path ⇒ Object
The CLI path.
-
.ruby ⇒ Object
Ruby VM installed in OS.
-
.run(*args) ⇒ Object
Look command in CLI directory and execute (by exec).
-
.source(command) ⇒ Object
Source command placed in CLI directory.
-
.templates ⇒ Object
List all templates as commands.
Class Method Details
.commands ⇒ Object
List of commands placed in lib/prigner/cli/
.
27 28 29 30 31 |
# File 'lib/prigner/cli.rb', line 27 def self.commands Dir["#{path}/*.rb"].map do |source| File.basename(source, ".rb") end.sort end |
.path ⇒ Object
The CLI path.
15 16 17 |
# File 'lib/prigner/cli.rb', line 15 def self.path "#{Prigner::ROOT}/lib/prigner/cli" end |
.ruby ⇒ Object
Ruby VM installed in OS.
9 10 11 12 |
# File 'lib/prigner/cli.rb', line 9 def self.ruby File.join(*::RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) + ::RbConfig::CONFIG["EXEEXT"] end |
.run(*args) ⇒ Object
Look command in CLI directory and execute (by exec).
39 40 41 42 43 44 |
# File 'lib/prigner/cli.rb', line 39 def self.run(*args) command = args.shift if commands.include? args.first raise RuntimeError, "unknown command '#{args.first}'" unless command rubyopt = "-I#{Prigner::ROOT}/lib" exec ruby, rubyopt, source(command), *args end |
.source(command) ⇒ Object
Source command placed in CLI directory.
34 35 36 |
# File 'lib/prigner/cli.rb', line 34 def self.source(command) "#{path}/#{command}.rb" end |