Module: Helpema::Rubish

Extended by:
Piper, Rubish
Included in:
Rubish
Defined in:
lib/helpema/rubish.rb

Class Method Summary collapse

Methods included from Piper

define_command, run_command, to_arg, validate_command

Class Method Details

.command(name, cmd: name.to_s.chomp('?').chomp('!'), version: nil, v: nil, usage: nil, synonyms: nil, exception: nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/helpema/rubish.rb', line 26

def Rubish.command(name,
                  cmd:name.to_s.chomp('?').chomp('!'),
                  version:nil, v:nil,
                  usage:nil,   synonyms:nil, exception:nil)
  mode = 'r'
  exception = false if name[-1]=='?' and not exception
  Rubish.define_command(name.to_sym,
                        cmd:cmd,
                        version:version, v:v,
                        usage:usage,     synonyms:synonyms,
                        mode:mode,       exception:exception)
end

.shell(name, cmd: name.to_s.chomp('?').chomp('!'), version: nil, v: nil, usage: nil, synonyms: nil, exception: nil, default: nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/helpema/rubish.rb', line 4

def Rubish.shell(name,
                 cmd:name.to_s.chomp('?').chomp('!'),
                 version:nil,    v:nil,
                 usage:nil,      synonyms:nil,
                 exception:nil,  default:nil)
  if name[-1]=='?'
    mode = 'w'
    exception = false unless exception
  else
    mode = 'w+'
  end
  Rubish.define_command(name.to_sym,
                        cmd:cmd,
                        version:version, v:v,
                        usage:usage,     synonyms:synonyms,
                        mode:mode,       exception:exception,
                        default:default) # default script
end