Class: Milkode::CLI

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

Instance Method Summary collapse

Instance Method Details

#add(*args) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/milkode/cli.rb', line 48

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

#cleanup(*args) ⇒ Object



109
110
111
# File 'lib/milkode/cli.rb', line 109

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

#config(*args) ⇒ Object



244
245
246
# File 'lib/milkode/cli.rb', line 244

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

#dir(*args) ⇒ Object



127
128
129
# File 'lib/milkode/cli.rb', line 127

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

#dumpObject



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

def dump
  cdstk.dump
end

#fav(*paths) ⇒ Object



171
172
173
# File 'lib/milkode/cli.rb', line 171

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

#files(*args) ⇒ Object



227
228
229
# File 'lib/milkode/cli.rb', line 227

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

#grep(*args) ⇒ Object



207
208
209
# File 'lib/milkode/cli.rb', line 207

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

#ignore(*paths) ⇒ Object



160
161
162
163
164
165
166
# File 'lib/milkode/cli.rb', line 160

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

#info(*args) ⇒ Object



150
151
152
# File 'lib/milkode/cli.rb', line 150

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

#init(db_dir = nil) ⇒ Object



17
18
19
20
21
# File 'lib/milkode/cli.rb', line 17

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



94
95
96
# File 'lib/milkode/cli.rb', line 94

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

#mcdObject



139
140
141
# File 'lib/milkode/cli.rb', line 139

def mcd
  cdstk.mcd(options)
end

#plugins(*args) ⇒ Object



213
214
215
216
217
218
219
220
221
222
# File 'lib/milkode/cli.rb', line 213

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



100
101
102
# File 'lib/milkode/cli.rb', line 100

def pwd()
  cdstk.pwd(options)
end

#rebuild(*args) ⇒ Object



116
117
118
# File 'lib/milkode/cli.rb', line 116

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

#remove(*args) ⇒ Object



68
69
70
71
72
73
74
75
76
# File 'lib/milkode/cli.rb', line 68

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



82
83
84
85
86
87
88
# File 'lib/milkode/cli.rb', line 82

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

#setdb(*args) ⇒ Object



133
134
135
# File 'lib/milkode/cli.rb', line 133

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

#update(*args) ⇒ Object



60
61
62
# File 'lib/milkode/cli.rb', line 60

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

#webObject



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/milkode/cli.rb', line 185

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