Sha256: 5989ef9401a806cc2494ca708efc3f98bfa445e9abb9aa1dd9a6729f845d0f2b
Contents?: true
Size: 699 Bytes
Versions: 1
Compression:
Stored size: 699 Bytes
Contents
module MyScripts # Base class for all scripts. Subclass it and override run method with actual # work your script will be doing class Script def initialize( name, argv, cli ) @name = name @argv = argv @cli = cli end def run end def puts *args @cli.stdout.puts *args nil end def gets @cli.stdin.gets end def usage examples, explanation = nil puts "Usage:" puts (examples.respond_to?(:split) ? examples.split("\n") : examples).map {|line| " #{@name} #{line}"} puts explanation if explanation exit 1 end def to_s "#{@name} #{@argv.join(' ')} -> #{self.class}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
my_scripts-0.0.19 | lib/my_scripts/script.rb |