Class: Smith::Commands::Version

Inherits:
Smith::CommandBase show all
Defined in:
lib/smith/commands/agency/version.rb

Instance Attribute Summary

Attributes inherited from Smith::CommandBase

#options, #target

Instance Method Summary collapse

Methods inherited from Smith::CommandBase

#banner, #format_help, #initialize, #parse_options

Methods included from Logger

included

Constructor Details

This class inherits a constructor from Smith::CommandBase

Instance Method Details

#executeObject



5
6
7
8
9
# File 'lib/smith/commands/agency/version.rb', line 5

def execute
  version do |v|
    responder.succeed(v)
  end
end

#version(&blk) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/smith/commands/agency/version.rb', line 11

def version(&blk)
  if options[:git]
    # EM.system doesn't do any shell expansion so do it ourselves.
    EM.system("sh -c 'git describe 2> /dev/null'") do |output,status|
      blk.call((status.exitstatus == 0) ? output.strip : 'The agency is not running in a git repo.')
    end
  else
    blk.call(Smith::VERSION)
  end
end