Class: BuildTool::Commands::Recipes::Add

Inherits:
Standard show all
Defined in:
lib/build-tool/commands/recipes/add.rb

Overview

BuildCommand

Instance Attribute Summary

Attributes inherited from Base

#cmd, #options, #parent

Instance Method Summary collapse

Methods inherited from Standard

#complete_module, #complete_modules, #initialize, #log_directory, #while_logging_to

Methods inherited from Base

#<=>, #applicable?, #cleanup_after_vcs_access, #complete_arguments, #complete_readline, #configuration, #debug, #debug2, #do_complete, #each_option, #error, #execute, #fullname, #info, #initialize, #log?, #quiet, #setup_command, #setup_options, #show_help, #skip_command, #summarize, #teardown_command, #trace, #usage, #verbose, #warn

Methods included from HelpText

#cmdalias, #description, included, #long_description, #name

Constructor Details

This class inherits a constructor from BuildTool::Commands::Standard

Instance Method Details

#do_execute(args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/build-tool/commands/recipes/add.rb', line 27

def do_execute( args )
    if ( args.length < 2 )
        return usage( "Not enough arguments" )
    elsif (args.length > 2 )
        return usage( "To many arguments" )
    end

    if not MJ::VCS::Git.git_available?
        raise RecipeError, 'Can\'t add recipe because git is not available'
    end

    path = BuildTool::Application::instance.local_configuration_dir.join( "recipes" )
    if ! path.exist? && ! $noop
        FileUtils.mkdir_p( path )
    end

    repo = MJ::VCS::Git::Repository.new(path.join(args[1]), $noop)

    branch = 'build-tool-%s' % BuildTool::VERSION.recipe_version()
    repo.clone(args[0], branch )

    logger.info( "Cloned the recipe to #{path.join(args[1] )}" )
    return 0
end

#initialize_optionsObject



20
21
22
23
24
25
# File 'lib/build-tool/commands/recipes/add.rb', line 20

def initialize_options
    options.banner = "Usage: #{self.fullname} [OPTIONS]... URL NAME"
    options.separator( "" )
    options.separator( "Options" )
    super
end