Class: Wisco::CLI
- Inherits:
-
Thor
- Object
- Thor
- Wisco::CLI
- Defined in:
- lib/wisco.rb
Class Method Summary collapse
- .exit_on_failure? ⇒ Boolean
-
.start(given_args = ARGV, config = {}) ⇒ Object
Rewrite ‘wisco <command> –help` → `wisco help <command>` so Thor shows per-command help instead of treating –help as a positional argument.
Instance Method Summary collapse
- #exec(path_arg, target_dir = nil) ⇒ Object
- #fixtures(path_arg, target_dir = nil) ⇒ Object
- #init(path = nil) ⇒ Object
- #list(subcommand = nil, path = nil) ⇒ Object
- #pull(target_dir = nil) ⇒ Object
- #push(target_dir = nil) ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
31 32 33 |
# File 'lib/wisco.rb', line 31 def self.exit_on_failure? true end |
.start(given_args = ARGV, config = {}) ⇒ Object
Rewrite ‘wisco <command> –help` → `wisco help <command>` so Thor shows per-command help instead of treating –help as a positional argument.
37 38 39 40 41 42 43 44 45 |
# File 'lib/wisco.rb', line 37 def self.start(given_args = ARGV, config = {}) if given_args.length >= 2 && (given_args.include?('--help') || given_args.include?('-h')) && !given_args.first.start_with?('-') super(['help', given_args.first], config) else super end end |
Instance Method Details
#exec(path_arg, target_dir = nil) ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/wisco.rb', line 91 def exec(path_arg, target_dir = nil) Wisco::Commands::Exec.run( path_arg, target_dir || Dir.pwd, input: [:input], pagination: [:pagination], verbose: [:verbose], debug: [:debug] ) end |
#fixtures(path_arg, target_dir = nil) ⇒ Object
114 115 116 117 118 119 120 121 |
# File 'lib/wisco.rb', line 114 def fixtures(path_arg, target_dir = nil) Wisco::Commands::Fixtures.run( path_arg, target_dir || Dir.pwd, overwrite: [:overwrite], debug: [:debug] ) end |
#init(path = nil) ⇒ Object
55 56 57 |
# File 'lib/wisco.rb', line 55 def init(path = nil) Wisco::Commands::Init.run(path || Dir.pwd) end |
#list(subcommand = nil, path = nil) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/wisco.rb', line 68 def list(subcommand = nil, path = nil) if subcommand&.match?(%r{^[./~\\]|^[A-Za-z]:[/\\]}) path = subcommand subcommand = nil end Wisco::Commands::List.run(subcommand, path || Dir.pwd, sort: [:sort]) end |
#pull(target_dir = nil) ⇒ Object
159 160 161 162 163 164 165 166 |
# File 'lib/wisco.rb', line 159 def pull(target_dir = nil) Wisco::Commands::Pull.run( target_dir || Dir.pwd, what: [:what], title: [:title], debug: [:debug] ) end |
#push(target_dir = nil) ⇒ Object
134 135 136 137 138 139 140 141 142 143 |
# File 'lib/wisco.rb', line 134 def push(target_dir = nil) Wisco::Commands::Push.run( target_dir || Dir.pwd, title: [:title], notes: [:notes], folder: [:folder], verbose: [:verbose], debug: [:debug] ) end |
#version ⇒ Object
49 50 51 |
# File 'lib/wisco.rb', line 49 def version puts "#{DISPLAY_NAME} v#{VERSION}" end |