Class: Fudge::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/fudge/cli.rb

Overview

Fudge command line interface

Instance Method Summary collapse

Instance Method Details

#build(build_name = 'default') ⇒ Object

Runs the parsed builds

Parameters:

  • build_name (String) (defaults to: 'default')

    the given build to run (default ‘default’)



20
21
22
23
# File 'lib/fudge/cli.rb', line 20

def build(build_name='default')
  description = Fudge::Parser.new.parse('Fudgefile')
  Fudge::Runner.new(description).run_build(build_name, options)
end

#initObject

Initalizes the blank Fudgefile



8
9
10
11
12
# File 'lib/fudge/cli.rb', line 8

def init
  generator = Fudge::Generator.new(Dir.pwd)
  msg = generator.write_fudgefile
  shell.say msg
end

#list(filter = "") ⇒ Object

Lists builds defined in Fudgefile, with optional filtering.

If given no filter, all builds are listed. If given a filter, lists builds whose names match the filter. Matching is based on sub-string matching and is case insensitive.

The listing includes the build name, followed by the about string if one was specified in the Fudgefile.

Parameters:

  • filter (String) (defaults to: "")

    a string by which to filter the builds listed



37
38
39
40
41
42
# File 'lib/fudge/cli.rb', line 37

def list(filter="")
  description = Fudge::Parser.new.parse('Fudgefile')
  builds = description.builds.map { |name, build| ["#{name}", build.about] }
  matches = builds.select { |name, _| name =~ /#{filter}/i }
  shell.print_table(matches, :indent => 2, :truncate => true)
end