Class: RepoManager::ListAction
- Inherits:
-
AppAction
- Object
- BaseAction
- AppAction
- RepoManager::ListAction
- Includes:
- ActionHelper
- Defined in:
- lib/repo_manager/actions/list_action.rb
Overview
List assets to the screen or file with or without templates using regular expression (regex) filtering.
Instance Attribute Summary
Attributes inherited from BaseAction
#args, #configuration, #exit_code, #option_parser, #options, #output, #template
CLI actions collapse
- #help ⇒ Object
-
#parse_options ⇒ Object
Add action specific options.
- #render(view_options = configuration) ⇒ Object
Methods included from ActionHelper
#relative_path, #shell_quote, #windows?
Methods inherited from AppAction
Methods inherited from BaseAction
#after_execute, #asset_options, #asset_type, #assets, #before_execute, #execute, #initialize, #items, #overwrite_output?, #process, #write_to_output
Constructor Details
This class inherits a constructor from RepoManager::BaseAction
Instance Method Details
#help ⇒ Object
118 119 120 |
# File 'lib/repo_manager/actions/list_action.rb', line 118 def help super :comment_starting_with => "List assets", :located_in_file => __FILE__ end |
#parse_options ⇒ Object
Add action specific options
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/repo_manager/actions/list_action.rb', line 67 def super do |opts| opts.on("--list MODE", "Listing mode. ALL, NAME, SHORT, PATH") do |u| [:list] = u [:list].upcase! unless ["ALL", "NAME", "SHORT", "PATH"].include?([:list]) raise "invalid list mode '#{options[:list]}' for '--list' option" end end opts.on("--short", "List summary status only, alias for '--list=SHORT'") do |s| [:list] = 'SHORT' end # Most decendants of BaseAction will only handle one type of asset, the # list action is unique in that you can specify the type of asset to list opts.on("--type ASSET_TYPE", "Asset type to list: app_asset (default)") do |t| [:type] = t unless ["app_asset"].include?([:type]) raise "unknown asset type '#{options[:type]}' for '--type' option" end end end end |
#render(view_options = configuration) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/repo_manager/actions/list_action.rb', line 94 def render(=configuration) # templates override all other modes, if no mode specified, allow super to handle list_mode = [:template] || [:list] result = "" case list_mode when 'NAME' items.each do |item| result += "#{item.name.green}\n" end when 'SHORT' items.each do |item| result += item.name.green result += ": #{relative_path(item.path)}\n" end when 'PATH' items.each do |item| result += "#{item.path}\n" end else result = super() end result end |