Sha256: fde4e023fc1669f256bf904c2e2d904737ecf4294d8750b1583ff99db7fe9194
Contents?: true
Size: 1.88 KB
Versions: 6
Compression:
Stored size: 1.88 KB
Contents
# -*- coding: UTF-8 -*- require 'build-tool/commands' require 'build-tool/recipe' require 'fileutils' module BuildTool; module Commands; module Recipes # # BuildCommand # class Edit < Standard name "edit" description "Edit the recipe." long_description [ "Opens the recipe in a editor (or file browser). By default opens the override file.", "The command uses xdg-open." ] def applicable? BuildTool::Application.instance.has_recipe? end 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 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 system( 'xdg-open %s' % [ rec.global_path ] ) else system( 'xdg-open %s' % [ rec.global_config_file_path( 'recipe' ) ] ) end else if @browser system( 'xdg-open %s' % [ rec.local_path() ] ) else system( 'xdg-open %s' % [ rec.local_config_file_path( 'recipe' ) ] ) end end return 0 end end # class end; end # module Commands::Recipes end; # module BuildTool
Version data entries
6 entries across 6 versions & 1 rubygems