Class: BuildTool::Commands::Recipes::Edit

Inherits:
Standard show all
Defined in:
lib/build-tool/commands/recipes/edit.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

#<=>, #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

#applicable?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/build-tool/commands/recipes/edit.rb', line 22

def applicable?
    BuildTool::Application.instance.has_recipe?
end

#do_execute(args) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/build-tool/commands/recipes/edit.rb', line 42

def do_execute( args )
    if ( args.length > 0 )
        return usage( args.length == 0 ?  "Not enough arguments" : "To many arguments" )
    end

    rec = BuildTool::Application::instance.recipe

    if @global
        if @browser
            MJ::Path::open( rec.global_path )
        else
            MJ::Path::open( rec.global_config_file_path( 'recipe' ) )
        end
    else
        if @browser
            MJ::Path::open( rec.local_path() )
        else
            MJ::Path::open( rec.local_config_file_path( 'recipe' ) )
        end
    end
    return 0
end

#initialize_optionsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/build-tool/commands/recipes/edit.rb', line 26

def initialize_options
    options.banner = "Usage: #{self.fullname} RECIPE [OPTIONS]... MODULE"
    options.separator( "" )
    options.separator( "Options" )

    @global = false
    options.on( "-g", "--global", "Open the recipe." ) { |t|
        @global = t
        }
    @browser = false
    options.on( "-b", "--browser", "Open a file browser." ) { |t|
        @browser = t
        }
    super
end