Class: Guard::CLI

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

Overview

Facade for the Guard command line interface managed by [Thor](github.com/wycats/thor). This is the main interface to Guard that is called by the Guard binary `bin/guard`. Do not put any logic in here, create a class and delegate instead.

Instance Method Summary collapse

Instance Method Details

#init(*plugin_names) ⇒ Object

Initializes the templates of all installed Guard plugins and adds them to the `Guardfile` when no Guard name is passed. When passing Guard plugin names it does the same but only for those Guard plugins.

Parameters:

  • plugin_names (Array<String>)

    the name of the Guard plugins to initialize

See Also:



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/guard/cli.rb', line 165

def init(*plugin_names)
  _verify_bundler_presence

  ::Guard::Guardfile.create_guardfile(abort_on_existence: options[:bare])

  return if options[:bare]

  if plugin_names.empty?
    ::Guard::Guardfile.initialize_all_templates
  else
    plugin_names.each do |plugin_name|
      ::Guard::Guardfile.initialize_template(plugin_name)
    end
  end
end

#listObject

List the Guard plugins that are available for use in your system and marks those that are currently used in your `Guardfile`.

See Also:

  • DslDescriber.list


123
124
125
# File 'lib/guard/cli.rb', line 123

def list
  ::Guard::DslDescriber.new(options).list
end

#notifiersObject

List the Notifiers for use in your system.

See Also:

  • DslDescriber.notifiers


133
134
135
# File 'lib/guard/cli.rb', line 133

def notifiers
  ::Guard::DslDescriber.new(options).notifiers
end

#showObject

Shows all Guard plugins and their options that are defined in the `Guardfile`

See Also:

  • DslDescriber.show


189
190
191
# File 'lib/guard/cli.rb', line 189

def show
  ::Guard::DslDescriber.new(options).show
end

#startObject

Start Guard by initializing the defined Guard plugins and watch the file system. This is the default task, so calling `guard` is the same as calling `guard start`.

See Also:



105
106
107
108
109
110
111
112
113
114
# File 'lib/guard/cli.rb', line 105

def start
  _verify_bundler_presence unless options[:no_bundler_warning]
  ::Guard.start(options)

  return if ENV['GUARD_ENV'] == 'test'

  while ::Guard.running do
    sleep 0.5
  end
end

#versionObject

Shows the current version of Guard.

See Also:



144
145
146
# File 'lib/guard/cli.rb', line 144

def version
  puts "Guard version #{ ::Guard::VERSION }"
end