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



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

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

#config(*args) ⇒ Object



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

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

#dir(*args) ⇒ Object



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

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

#dumpObject



107
108
109
# File 'lib/milkode/cli.rb', line 107

def dump
  cdstk.dump
end

#fav(*paths) ⇒ Object



157
158
159
# File 'lib/milkode/cli.rb', line 157

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

#files(*args) ⇒ Object



213
214
215
# File 'lib/milkode/cli.rb', line 213

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

#grep(*args) ⇒ Object



193
194
195
# File 'lib/milkode/cli.rb', line 193

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

#ignore(*paths) ⇒ Object



146
147
148
149
150
151
152
# File 'lib/milkode/cli.rb', line 146

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

#info(*args) ⇒ Object



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

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



80
81
82
# File 'lib/milkode/cli.rb', line 80

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

#mcdObject



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

def mcd
  cdstk.mcd(options)
end

#plugins(*args) ⇒ Object



199
200
201
202
203
204
205
206
207
208
# File 'lib/milkode/cli.rb', line 199

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



86
87
88
# File 'lib/milkode/cli.rb', line 86

def pwd()
  cdstk.pwd(options)
end

#rebuild(*args) ⇒ Object



102
103
104
# File 'lib/milkode/cli.rb', line 102

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

#remove(*args) ⇒ Object



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

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

#setdb(*args) ⇒ Object



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

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



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/milkode/cli.rb', line 171

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