module Scriptster
The public interface of scriptster is simple. It consists of two functions, cmd and log. The module can be used directly or included in your class.
Constants
- VERSION
The version of this library
Public Class Methods
cmd(*args)
click to toggle source
Execute a shell command
@see ShellCmd
# File lib/scriptster.rb, line 53 def self.cmd(*args) ShellCmd.new *args end
configure() { |c| ... }
click to toggle source
Use this method to reconfigure the library.
@example
Scriptster::configure do |conf| conf.name = "my-script" conf.colours = :light conf.timestamps = false end
@yield [c] An instance of the {Configuration} class. @see Configuration
# File lib/scriptster.rb, line 75 def self.configure c = Configuration.new yield c c.apply end
log(*args)
click to toggle source
Pass a message to the logger.
@see Logger.log
# File lib/scriptster.rb, line 39 def self.log(*args) Logger::log *args end
parse_args(docopt_string, argv=nil)
click to toggle source
Process command line arguments using docopt and return the array of options.
@param [String] docopt_string The interface spec to be passed to docopt. @return [Array] The processed CLI options, straight from docopt.
# File lib/scriptster.rb, line 86 def self.parse_args(docopt_string, argv=nil) do_parse_args docopt_string, argv end
Private Class Methods
do_parse_args(docopt_string, argv=nil)
click to toggle source
# File lib/scriptster.rb, line 98 def self.do_parse_args(docopt_string, argv=nil) begin return Docopt::docopt docopt_string, argv: argv rescue Docopt::Exit => e STDERR.puts e.message exit 1 end end
Public Instance Methods
cmd(*args)
click to toggle source
The same as {Scriptster.cmd}.
@see .cmd
# File lib/scriptster.rb, line 60 def cmd(*args) Scriptster.cmd *args end
log(*args)
click to toggle source
The same as {Scriptster.log}.
@see .log
# File lib/scriptster.rb, line 46 def log(*args) Scriptster.log *args end
parse_args(docopt_string, argv=nil)
click to toggle source
The same as {Scriptster.parse_args}.
@see .parse_args
# File lib/scriptster.rb, line 93 def parse_args(docopt_string, argv=nil) Scriptster.do_parse_args docopt_string, argv end