Class: Milkode::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/milkode/cli.rb', line 11

def self.exit_on_failure?
  true
end

Instance Method Details

#add(*args) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/milkode/cli.rb', line 52

def add(*args)
  if args.empty? && !options[:from_file]
    CLI.task_help(shell, "add")
  else
    cdstk.add(args, options)
  end
end

#cleanup(*args) ⇒ Object



113
114
115
# File 'lib/milkode/cli.rb', line 113

def cleanup(*args)
  cdstk.cleanup(args, options)
end

#config(*args) ⇒ Object



248
249
250
# File 'lib/milkode/cli.rb', line 248

def config(*args)
  cdstk.config(args, options)
end

#dir(*args) ⇒ Object



131
132
133
# File 'lib/milkode/cli.rb', line 131

def dir(*args)
  cdstk.dir(args, options)
end

#dumpObject



125
126
127
# File 'lib/milkode/cli.rb', line 125

def dump
  cdstk.dump
end

#fav(*paths) ⇒ Object



175
176
177
# File 'lib/milkode/cli.rb', line 175

def fav(*paths)
  cdstk.fav(paths, options)
end

#files(*args) ⇒ Object



231
232
233
# File 'lib/milkode/cli.rb', line 231

def files(*args)
  cdstk.files(args, options)
end

#grep(*args) ⇒ Object



211
212
213
# File 'lib/milkode/cli.rb', line 211

def grep(*args)
  Milkode::CLI_Grep.execute($stdout, args)
end

#ignore(*paths) ⇒ Object



164
165
166
167
168
169
170
# File 'lib/milkode/cli.rb', line 164

def ignore(*paths)
  begin
    cdstk.ignore(paths, options)
  rescue IgnoreError => e
    $stdout.puts e.message
  end
end

#info(*args) ⇒ Object



154
155
156
# File 'lib/milkode/cli.rb', line 154

def info(*args)
  cdstk.info(args_or_pipe(args, $stdin), options)
end

#init(db_dir = nil) ⇒ Object



21
22
23
24
25
# File 'lib/milkode/cli.rb', line 21

def init(db_dir = nil)
  db_dir = db_dir || Dbdir.default_dir
  FileUtils.mkdir_p db_dir
  cdstk(db_dir).init(options)
end

#list(*args) ⇒ Object



98
99
100
# File 'lib/milkode/cli.rb', line 98

def list(*args)
  cdstk.list(args, options)
end

#mcdObject



143
144
145
# File 'lib/milkode/cli.rb', line 143

def mcd
  cdstk.mcd(options)
end

#plugins(*args) ⇒ Object



217
218
219
220
221
222
223
224
225
226
# File 'lib/milkode/cli.rb', line 217

def plugins(*args)
  $stdout.puts <<EOF
bundle-milkode      https://github.com/kou/bundle-milkode
emacs-milkode       https://github.com/ongaeshi/emacs-milkode
gem-milkode         https://github.com/kou/gem-milkode 
Gitomb              https://github.com/tomykaira/gitomb
Milkode_Sublime     https://github.com/tsurushuu/Milkode_Sublime
redmine_milkode     https://github.com/suer/redmine_milkode
EOF
end

#pwdObject



104
105
106
# File 'lib/milkode/cli.rb', line 104

def pwd()
  cdstk.pwd(options)
end

#rebuild(*args) ⇒ Object



120
121
122
# File 'lib/milkode/cli.rb', line 120

def rebuild(*args)
  cdstk.rebuild(args, options)
end

#remove(*args) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/milkode/cli.rb', line 72

def remove(*args)
  $stdout.puts "[warning] 'milk remove' is obsolete. Please use 'milk rm'."

  if args.empty? && !options[:all]
    CLI.task_help(shell, "remove")
  else
    cdstk.remove(args, options)
  end
end

#rm(*args) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/milkode/cli.rb', line 86

def rm(*args)
  if args.empty? && !options[:all]
    CLI.task_help(shell, "remove")
  else
    cdstk.remove(args, options)
  end
end

#setdb(*args) ⇒ Object



137
138
139
# File 'lib/milkode/cli.rb', line 137

def setdb(*args)
  cdstk.setdb(args, options)
end

#update(*args) ⇒ Object



64
65
66
# File 'lib/milkode/cli.rb', line 64

def update(*args)
  cdstk.update(args, options)
end

#webObject



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/milkode/cli.rb', line 189

def web
  opts = {
    :environment => ENV['RACK_ENV'] || "development",
    :pid         => nil,
    :Port        => options[:port],
    :Host        => options[:host],
    :AccessLog   => [],
    :config      => "config.ru",
    # ----------------------------
    :server        => options[:server],
    :LaunchBrowser => !options[:no_browser],
    :DbDir         => options[:db],
    :url           => options[:url],
    :gomilk        => options[:gomilk]
  }
  opts[:customize] = options[:customize]
  # cdstk(opts[:DbDir]).assert_compatible
  Milkode::CLI_Cdweb.execute_with_options($stdout, opts)
end