Module: DotFiles::DSL

Extended by:
DSL
Included in:
DSL
Defined in:
lib/dot_files/dsl.rb

Instance Method Summary collapse

Instance Method Details

#command(command, options = {}, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/dot_files/dsl.rb', line 6

def command(command, options = {}, &block)
  @commands = Hash.new if @commands.nil?
  @commands[command] = Hash.new
  @commands[command][:description] = @next_description
  @commands[command][:usage] = @next_usage
  @commands[command][:flags] = @next_flags
  @commands[command][:required_args] = (options[:required_args] || 0)
  @commands[command][:block] = Command.new(block)
  @next_usage, @next_description, @next_flags = nil, nil, nil
end

#commandsObject



17
18
19
# File 'lib/dot_files/dsl.rb', line 17

def commands
  @commands || Hash.new
end

#desc(value) ⇒ Object



21
22
23
# File 'lib/dot_files/dsl.rb', line 21

def desc(value)
  @next_description = value
end

#flag(key, value) ⇒ Object



29
30
31
32
# File 'lib/dot_files/dsl.rb', line 29

def flag(key, value)
  @next_flags = Hash.new if @next_flags.nil?
  @next_flags[key] = value
end

#usage(value) ⇒ Object



25
26
27
# File 'lib/dot_files/dsl.rb', line 25

def usage(value)
  @next_usage = value
end