Class: Pennyworth::CLI
- Inherits:
-
Thor
- Object
- Thor
- Pennyworth::CLI
- Includes:
- Thor::Actions, ThorPlus::Actions
- Defined in:
- lib/pennyworth/cli.rb
Class Method Summary collapse
-
.source_root ⇒ Object
Overwrites the Thor template source root.
Instance Method Summary collapse
- #edit ⇒ Object
- #help(task = nil) ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ CLI
constructor
Initialize.
- #install ⇒ Object
- #string ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ CLI
Initialize.
17 18 19 20 21 |
# File 'lib/pennyworth/cli.rb', line 17 def initialize args = [], = {}, config = {} super args, , config @settings_file = File.join ENV["HOME"], ".pennyworth", "settings.yml" @settings = load_yaml @settings_file end |
Class Method Details
.source_root ⇒ Object
Overwrites the Thor template source root.
12 13 14 |
# File 'lib/pennyworth/cli.rb', line 12 def self.source_root File. File.join(File.dirname(__FILE__), "templates") end |
Instance Method Details
#edit ⇒ Object
74 75 76 |
# File 'lib/pennyworth/cli.rb', line 74 def edit `$EDITOR #{@settings_file}` end |
#help(task = nil) ⇒ Object
85 86 87 |
# File 'lib/pennyworth/cli.rb', line 85 def help task = nil say and super end |
#install ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pennyworth/cli.rb', line 51 def install say if valid_file?(@settings[:alfred_settings_root], "Invalid directory for Alfred settings root") if yes? "Installing Alfred Extensions will destroy exiting extensions of the same name. Continue (y/n)?" info "Installing Alfred Extensions..." info "Alfred settings root: #{@settings[:alfred_settings_root]}" %w(files scripts).each do |folder| directory File.join("alfred", "extensions", folder), File.join(@settings[:alfred_settings_root], "extensions", folder) end info "Alfred Extensions installed." else info "Alfred Extenions installation cancelled." end else error "Invalid directory for Alfred settings root: #{@settings[:alfred_settings_root]}" end say end |
#string ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pennyworth/cli.rb', line 29 def string case when [:downcase] then string = Pennyworth::Kit.array_to_string [:downcase] puts Pennyworth::Kit.clip(string.downcase) when [:upcase] then string = Pennyworth::Kit.array_to_string [:upcase] puts Pennyworth::Kit.clip(string.upcase) when [:capitalize] then words = [:capitalize].map {|word| word.capitalize} words = Pennyworth::Kit.array_to_string words puts Pennyworth::Kit.clip(words) when [:length] then string = Pennyworth::Kit.array_to_string [:length] Pennyworth::Kit.clip(string) puts string.length else say("Type 'pennyworth help string' for usage.") end end |
#version ⇒ Object
80 81 82 |
# File 'lib/pennyworth/cli.rb', line 80 def version say "Pennyworth " + VERSION end |