Class: Wisco::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/wisco.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/wisco.rb', line 30

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.



36
37
38
39
40
41
42
43
44
# File 'lib/wisco.rb', line 36

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



87
88
89
90
91
92
93
94
# File 'lib/wisco.rb', line 87

def exec(path_arg, target_dir = nil)
  Wisco::Commands::Exec.run(
    path_arg,
    target_dir || Dir.pwd,
    input: options[:input],
    debug: options[:debug]
  )
end

#fixtures(path_arg, target_dir = nil) ⇒ Object



108
109
110
111
112
113
114
115
# File 'lib/wisco.rb', line 108

def fixtures(path_arg, target_dir = nil)
  Wisco::Commands::Fixtures.run(
    path_arg,
    target_dir || Dir.pwd,
    overwrite: options[:overwrite],
    debug:     options[:debug]
  )
end

#init(path = nil) ⇒ Object



54
55
56
# File 'lib/wisco.rb', line 54

def init(path = nil)
  Wisco::Commands::Init.run(path || Dir.pwd)
end

#list(subcommand = nil, path = nil) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/wisco.rb', line 67

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: options[:sort])
end

#pull(target_dir = nil) ⇒ Object



153
154
155
156
157
158
159
160
# File 'lib/wisco.rb', line 153

def pull(target_dir = nil)
  Wisco::Commands::Pull.run(
    target_dir || Dir.pwd,
    what:  options[:what],
    title: options[:title],
    debug: options[:debug]
  )
end

#push(target_dir = nil) ⇒ Object



128
129
130
131
132
133
134
135
136
137
# File 'lib/wisco.rb', line 128

def push(target_dir = nil)
  Wisco::Commands::Push.run(
    target_dir || Dir.pwd,
    title:   options[:title],
    notes:   options[:notes],
    folder:  options[:folder],
    verbose: options[:verbose],
    debug:   options[:debug]
  )
end

#versionObject



48
49
50
# File 'lib/wisco.rb', line 48

def version
  puts "#{DISPLAY_NAME} v#{VERSION}"
end