Class: Birdwatcher::Commands::Resource
- Inherits:
-
Birdwatcher::Command
- Object
- Birdwatcher::Command
- Birdwatcher::Commands::Resource
- Defined in:
- lib/birdwatcher/commands/resource.rb
Constant Summary
Constants inherited from Birdwatcher::Command
Birdwatcher::Command::ARGUMENT_SEPARATOR
Constants included from Birdwatcher::Concerns::Concurrency
Birdwatcher::Concerns::Concurrency::DEFAULT_THREAD_POOL_SIZE
Constants included from Birdwatcher::Concerns::Core
Birdwatcher::Concerns::Core::DATA_DIRECTORY
Instance Attribute Summary
Attributes inherited from Birdwatcher::Command
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Birdwatcher::Command
auto_completion, auto_completion_strings, descendants, #execute, has_name?, meta, meta=
Methods included from Birdwatcher::Concerns::Concurrency
Methods included from Birdwatcher::Concerns::Persistence
included, #save_status, #save_user
Methods included from Birdwatcher::Concerns::Presentation
included, #make_status_summary_output, #make_url_summary_output, #make_user_details_output, #make_user_summary_output, #output_status_summary, #output_user_details, #output_user_summary, #page_text
Methods included from Birdwatcher::Concerns::Outputting
#confirm, #error, #fatal, included, #info, #line_separator, #newline, #output, #output_formatted, #task, #warn
Methods included from Birdwatcher::Concerns::Util
#escape_html, #excerpt, included, #parse_time, #pluralize, #strip_control_characters, #strip_html, #suppress_output, #suppress_warnings, #time_ago_in_words, #unescape_html
Methods included from Birdwatcher::Concerns::Core
#console, #current_workspace, #current_workspace=, #database, included, #klout_client, #read_data_file, #twitter_client
Class Method Details
.detailed_usage ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/birdwatcher/commands/resource.rb', line 10 def self.detailed_usage <<-USAGE The #{'resource'.bold} command can be used to execute commands from a file on disk. Resource files are simple text-based files containing one command per line. They can be very convenient for common or repetitive workflows. #{'USAGE:'.bold} #{'Execute commands from a resource file:'.bold} resource <FILE> USAGE end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/birdwatcher/commands/resource.rb', line 23 def run if !arguments? error("You must provide a path to a resource file") return false end filepath = File.(arguments.join(" ")) if !File.exists?(filepath) error("File #{filepath.bold} does not exist") return false end if !File.readable?(filepath) error("File #{filepath} is not readable") return false end File.read(filepath).each_line do |command| command.strip! next if command.empty? || command.start_with?("#") || command.start_with?("//") console.handle_input(command.strip) end end |