Class: Milkode::CLI

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

Instance Method Summary collapse

Instance Method Details

#add(*args) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/milkode/cli.rb', line 44

def add(*args)
  if args.empty?
    CLI.task_help(shell, "add")
  else
    cdstk.add(args, options)
  end
end

#cleanup(*args) ⇒ Object



91
92
93
# File 'lib/milkode/cli.rb', line 91

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

#config(*args) ⇒ Object



223
224
225
# File 'lib/milkode/cli.rb', line 223

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

#dir(*args) ⇒ Object



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

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

#dumpObject



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

def dump
  cdstk.dump
end

#fav(*paths) ⇒ Object



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

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

#files(*args) ⇒ Object



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

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

#grep(*args) ⇒ Object



186
187
188
# File 'lib/milkode/cli.rb', line 186

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

#ignore(*paths) ⇒ Object



142
143
144
145
146
147
148
# File 'lib/milkode/cli.rb', line 142

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

#info(*args) ⇒ Object



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

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

#init(db_dir = nil) ⇒ Object



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

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



76
77
78
# File 'lib/milkode/cli.rb', line 76

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

#mcdObject



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

def mcd
  cdstk.mcd(options)
end

#plugins(*args) ⇒ Object



192
193
194
195
196
197
198
199
200
201
# File 'lib/milkode/cli.rb', line 192

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



82
83
84
# File 'lib/milkode/cli.rb', line 82

def pwd()
  cdstk.pwd(options)
end

#rebuild(*args) ⇒ Object



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

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

#remove(*args) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/milkode/cli.rb', line 64

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

#setdb(*args) ⇒ Object



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

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

#update(*args) ⇒ Object



56
57
58
# File 'lib/milkode/cli.rb', line 56

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

#webObject



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/milkode/cli.rb', line 165

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],
  }
  opts[:customize] = options[:customize]
  # cdstk(opts[:DbDir]).assert_compatible
  Milkode::CLI_Cdweb.execute_with_options($stdout, opts)
end