my_help 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +0 -3
- data/Gemfile.lock +10 -9
- data/README.html +362 -0
- data/README.org +58 -157
- data/README.rdoc +6 -0
- data/README_en.org +131 -0
- data/Rakefile_gli +44 -0
- data/bin/my_help +67 -0
- data/lib/my_help.rb +5 -204
- data/lib/my_help/my_help_controll.rb +139 -0
- data/lib/my_help/org2yml.rb +8 -2
- data/lib/my_help/version.rb +1 -1
- data/lib/templates/org_help.org +18 -15
- data/my_help.gemspec +23 -33
- data/my_help.rdoc +5 -0
- metadata +85 -55
- data/Dockerfile.template +0 -13
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/docs/README_en.org +0 -164
- data/docs/diff_against_org_mode.org +0 -38
- data/docs/path_setting.org +0 -47
- data/exe/e_h +0 -4
- data/exe/emacs_help +0 -4
- data/exe/m_t +0 -4
- data/exe/my_help +0 -6
- data/exe/my_todo +0 -4
- data/exe/o_h +0 -4
- data/exe/org_help +0 -4
- data/lib/emacs_help.rb +0 -137
- data/lib/my_help/test.rb +0 -29
- data/lib/my_help/yml2org.rb +0 -34
- data/lib/my_help_thor.rb +0 -170
- data/lib/specific_help.rb +0 -171
- data/lib/specific_help_bu.rb +0 -233
- data/lib/specific_help_opt.rb +0 -71
- data/lib/specific_help_thor.rb +0 -172
- data/make_docker.sh +0 -5
data/lib/specific_help.rb
DELETED
@@ -1,171 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require "optparse"
|
3
|
-
require "yaml"
|
4
|
-
require "my_help/version"
|
5
|
-
require 'fileutils'
|
6
|
-
require 'colorize'
|
7
|
-
require 'my_help/org2yml'
|
8
|
-
require 'my_help/yml2org'
|
9
|
-
|
10
|
-
module SpecificHelp
|
11
|
-
class Command
|
12
|
-
|
13
|
-
def self.run(file,argv=[])
|
14
|
-
new(file, argv).execute
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(file,argv=[])
|
18
|
-
@source_file = file
|
19
|
-
@help_cont = OrgToYaml.new(file).help_cont
|
20
|
-
[:head,:license].each do |sym|
|
21
|
-
target = @help_cont[sym]
|
22
|
-
print target[:cont] if target != nil
|
23
|
-
end
|
24
|
-
@argv = argv
|
25
|
-
end
|
26
|
-
|
27
|
-
def execute
|
28
|
-
if @argv.size==0
|
29
|
-
if @source_file.include?('todo')
|
30
|
-
@argv << '--all'
|
31
|
-
else
|
32
|
-
@argv << '--help'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
command_parser = OptionParser.new do |opt|
|
36
|
-
opt.on('-v', '--version','show program Version.') { |v|
|
37
|
-
opt.version = MyHelp::VERSION
|
38
|
-
puts opt.ver
|
39
|
-
}
|
40
|
-
@help_cont.each_pair{|key,val|
|
41
|
-
next if key==:head or key==:license
|
42
|
-
opts = val[:opts]
|
43
|
-
opt.on(opts[:short],opts[:long],opts[:desc]) {disp_help(key)}
|
44
|
-
}
|
45
|
-
opt.on('--edit','edit help contents'){edit_help}
|
46
|
-
opt.on('--all','display all helps'){all_help}
|
47
|
-
opt.on('--store [item]','store [item] in backfile'){|item| store(item)}
|
48
|
-
opt.on('--remove [item]','remove [item] and store in backfile'){|item| remove(item) }
|
49
|
-
opt.on('--add [item]','add new [item]'){|item| add(item) }
|
50
|
-
opt.on('--backup_list [val]','show last [val] backup list'){|val| backup_list(val)}
|
51
|
-
end
|
52
|
-
begin
|
53
|
-
command_parser.parse!(@argv)
|
54
|
-
rescue=> eval
|
55
|
-
p eval
|
56
|
-
end
|
57
|
-
exit
|
58
|
-
end
|
59
|
-
|
60
|
-
def backup_list(val)
|
61
|
-
val = val || 10
|
62
|
-
print "\n ...showing last #{val} stored items in backup.\n"
|
63
|
-
backup=mk_backup_file(@source_file)
|
64
|
-
File.open(backup,'r'){|file|
|
65
|
-
backup_cont = YAML.load(File.read(backup))
|
66
|
-
backup_size = backup_cont.size
|
67
|
-
backup_size = backup_size>val.to_i ? val.to_i : backup_size
|
68
|
-
backup_keys = backup_cont.keys
|
69
|
-
backup_keys.reverse.each_with_index{|item,i|
|
70
|
-
break if i>=backup_size
|
71
|
-
line = item.to_s.split('_')
|
72
|
-
printf("%10s : %8s%8s\n",line[0],line[1],line[2])
|
73
|
-
}
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
def mk_backup_file(file)
|
78
|
-
path = File.dirname(file)
|
79
|
-
base = File.basename(file)
|
80
|
-
backup= File.join(path,"."+base)
|
81
|
-
FileUtils.touch(backup) unless File.exists?(backup)
|
82
|
-
return backup
|
83
|
-
end
|
84
|
-
|
85
|
-
def store(item)
|
86
|
-
if item==nil
|
87
|
-
print "spcify --store [item].\n"
|
88
|
-
exit
|
89
|
-
else
|
90
|
-
print "Trying to store #{item}\n"
|
91
|
-
end
|
92
|
-
backup=mk_backup_file(@source_file)
|
93
|
-
unless store_item = @help_cont[item.to_sym] then
|
94
|
-
print "No #{item} in this help. The items are following...\n"
|
95
|
-
keys = @help_cont.keys
|
96
|
-
keys.each{|key|
|
97
|
-
p key
|
98
|
-
}
|
99
|
-
exit
|
100
|
-
end
|
101
|
-
p store_name = item+"_"+Time.now.strftime("%Y%m%d_%H%M%S")
|
102
|
-
cont = {store_name.to_sym => store_item}
|
103
|
-
backup_cont=YAML.load(File.read(backup)) || {}
|
104
|
-
backup_cont[store_name.to_sym]=store_item
|
105
|
-
File.open(backup,'w'){|file| file.print(YAML.dump(backup_cont))}
|
106
|
-
end
|
107
|
-
|
108
|
-
def add(item='new_item')
|
109
|
-
print "Trying to add #{item}\n"
|
110
|
-
new_item={:opts=>{:short=>'-'+item[0], :long=>'--'+item, :desc=>item},
|
111
|
-
:title=>item, :cont=> item}
|
112
|
-
@help_cont[item.to_sym]=new_item
|
113
|
-
File.open(@source_file,'w'){|f| f.print YmlToOrg.new(@help_cont).contents}
|
114
|
-
end
|
115
|
-
|
116
|
-
def remove(item)
|
117
|
-
print "Trying to remove #{item}\n"
|
118
|
-
store(item)
|
119
|
-
@help_cont.delete(item.to_sym)
|
120
|
-
File.open(@source_file,'w'){|file| file.print YAML.dump(@help_cont)}
|
121
|
-
end
|
122
|
-
|
123
|
-
def edit_help
|
124
|
-
help_file =@source_file
|
125
|
-
begin
|
126
|
-
p command= "emacs #{help_file}"
|
127
|
-
exec command
|
128
|
-
rescue => e
|
129
|
-
print "\nOption edit is not executable on windows. \n"
|
130
|
-
print "Type the following shell command;\n\n"
|
131
|
-
print "emacs /home/#{ENV['USER']}/.my_help/#{File.basename(@source_file)}\n\n"
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def all_help
|
136
|
-
@help_cont.each_pair{|key,val|
|
137
|
-
if key==:head or key==:license
|
138
|
-
if val.kind_of?(Hash)
|
139
|
-
disp(val[:cont][0]+=":")
|
140
|
-
else
|
141
|
-
val[0]+=":"
|
142
|
-
disp(val)
|
143
|
-
end
|
144
|
-
else
|
145
|
-
disp_help(key)
|
146
|
-
end
|
147
|
-
}
|
148
|
-
end
|
149
|
-
|
150
|
-
def disp_help(key_word)
|
151
|
-
print_separater
|
152
|
-
items =@help_cont[key_word]
|
153
|
-
puts items[:title].magenta
|
154
|
-
disp(items[:cont])
|
155
|
-
print_separater
|
156
|
-
end
|
157
|
-
|
158
|
-
def disp(lines)
|
159
|
-
if lines.kind_of?(Array)
|
160
|
-
lines.each{|line| puts "* #{line}".blue}
|
161
|
-
else
|
162
|
-
print lines
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def print_separater
|
167
|
-
print "---\n"
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
end
|
data/lib/specific_help_bu.rb
DELETED
@@ -1,233 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require "optparse"
|
3
|
-
require "yaml"
|
4
|
-
require "my_help/version"
|
5
|
-
require 'fileutils'
|
6
|
-
require "coderay"
|
7
|
-
require 'colorize'
|
8
|
-
require "thor"
|
9
|
-
|
10
|
-
module SpecificHelp
|
11
|
-
class Command < Thor
|
12
|
-
=begin
|
13
|
-
def self.start(file,*args)
|
14
|
-
new(file, *args).execute
|
15
|
-
end
|
16
|
-
=end
|
17
|
-
|
18
|
-
def initialize(*args)
|
19
|
-
super
|
20
|
-
puts "@initialize\n"
|
21
|
-
# file = File.join(ENV['HOME'],'.my_help','test_help.yml'
|
22
|
-
# @source_file = file
|
23
|
-
@source_file = File.join(ENV['HOME'],'.my_help','test_help.yml')
|
24
|
-
# file = "/Users/OyagiToshiharu/.my_help/test_help.yml"
|
25
|
-
# @source_file = file
|
26
|
-
|
27
|
-
@help_cont = YAML.load(File.read(@source_file))
|
28
|
-
@help_cont[:head].each{|line| print line.chomp+"\n" } if @help_cont[:head] != nil
|
29
|
-
@help_cont[:license].each{|line| print "#{line.chomp}\n" } if @help_cont[:license] != nil
|
30
|
-
@argv = *args
|
31
|
-
end
|
32
|
-
|
33
|
-
desc 'backup NAME, --backup NAME','backup NAME help'
|
34
|
-
map "--backup" => "backup"
|
35
|
-
def backup(val)
|
36
|
-
val = val || 10
|
37
|
-
print "\n ...showing last #{val} stored items in backup.\n"
|
38
|
-
backup=mk_backup_file(@source_file)
|
39
|
-
File.open(backup,'r'){|file|
|
40
|
-
backup_cont = YAML.load(File.read(backup))
|
41
|
-
backup_size = backup_cont.size
|
42
|
-
backup_size = backup_size>val.to_i ? val.to_i : backup_size
|
43
|
-
backup_keys = backup_cont.keys
|
44
|
-
backup_keys.reverse.each_with_index{|item,i|
|
45
|
-
break if i>=backup_size
|
46
|
-
line = item.to_s.split('_')
|
47
|
-
printf("%10s : %8s%8s\n",line[0],line[1],line[2])
|
48
|
-
}
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
desc 'store NAME, --store','store NAME help'
|
53
|
-
map "--store" => "store"
|
54
|
-
def store(item)
|
55
|
-
if item==nil
|
56
|
-
print "spcify --store [item].\n"
|
57
|
-
exit
|
58
|
-
else
|
59
|
-
print "Trying to store #{item}\n"
|
60
|
-
end
|
61
|
-
backup=mk_backup_file(@source_file)
|
62
|
-
unless store_item = @help_cont[item.to_sym] then
|
63
|
-
print "No #{item} in this help. The items are following...\n"
|
64
|
-
keys = @help_cont.keys
|
65
|
-
keys.each{|key|
|
66
|
-
p key
|
67
|
-
}
|
68
|
-
exit
|
69
|
-
end
|
70
|
-
p store_name = item+"_"+Time.now.strftime("%Y%m%d_%H%M%S")
|
71
|
-
cont = {store_name.to_sym => store_item}
|
72
|
-
backup_cont=YAML.load(File.read(backup)) || {}
|
73
|
-
backup_cont[store_name.to_sym]=store_item
|
74
|
-
File.open(backup,'w'){|file| file.print(YAML.dump(backup_cont))}
|
75
|
-
end
|
76
|
-
|
77
|
-
desc 'add NAME, --add NAME','add NAME help'
|
78
|
-
map "--add" => "add"
|
79
|
-
def add(item='new_item')
|
80
|
-
print "Trying to add #{item}\n"
|
81
|
-
new_item={:opts=>{:short=>'-'+item[0], :long=>'--'+item, :desc=>item},
|
82
|
-
:title=>item, :cont=> [item]}
|
83
|
-
@help_cont[item.to_sym]=new_item
|
84
|
-
File.open(@source_file,'w'){|file| file.print YAML.dump(@help_cont)}
|
85
|
-
end
|
86
|
-
|
87
|
-
desc 'remove NAME, --remove NAME','remove NAME help'
|
88
|
-
map "--remove" => "remove"
|
89
|
-
def remove(item)
|
90
|
-
print "Trying to remove #{item}\n"
|
91
|
-
store(item)
|
92
|
-
@help_cont.delete(item.to_sym)
|
93
|
-
File.open(@source_file,'w'){|file| file.print YAML.dump(@help_cont)}
|
94
|
-
end
|
95
|
-
|
96
|
-
desc 'edit, --edit','edit help'
|
97
|
-
map "--edit" => "edit"
|
98
|
-
def edit
|
99
|
-
puts "@edit\n"
|
100
|
-
p help_file =@source_file
|
101
|
-
begin
|
102
|
-
p command= "emacs #{help_file}"
|
103
|
-
exec command
|
104
|
-
rescue => e
|
105
|
-
print "\nOption edit is not executable on windows. \n"
|
106
|
-
print "Type the following shell command;\n\n"
|
107
|
-
print "emacs /home/#{ENV['USER']}/.my_help/#{File.basename(@source_file)}\n\n"
|
108
|
-
print "M-x ruby-mode should be good for edit.\n"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
desc 'hiki, --hiki','hiki help'
|
113
|
-
map "--hiki" => "hiki"
|
114
|
-
def hiki
|
115
|
-
@help_cont.each_pair{|key,val|
|
116
|
-
if key==:head or key==:license
|
117
|
-
hiki_disp(val)
|
118
|
-
else
|
119
|
-
hiki_help(key)
|
120
|
-
end
|
121
|
-
}
|
122
|
-
end
|
123
|
-
|
124
|
-
desc 'all, --all','all help'
|
125
|
-
map "--all" => "all"
|
126
|
-
def all
|
127
|
-
@help_cont.each_pair{|key,val|
|
128
|
-
if key==:head or key==:license
|
129
|
-
val[0]+=":"
|
130
|
-
disp(val)
|
131
|
-
else
|
132
|
-
disp_help(key)
|
133
|
-
end
|
134
|
-
}
|
135
|
-
end
|
136
|
-
|
137
|
-
no_commands do
|
138
|
-
|
139
|
-
def mk_backup_file(file)
|
140
|
-
path = File.dirname(file)
|
141
|
-
base = File.basename(file)
|
142
|
-
backup= File.join(path,"."+base)
|
143
|
-
FileUtils.touch(backup) unless File.exists?(backup)
|
144
|
-
return backup
|
145
|
-
end
|
146
|
-
|
147
|
-
def hiki_help(key_word)
|
148
|
-
items =@help_cont[key_word]
|
149
|
-
puts "\n!!"+items[:title]+"\n"
|
150
|
-
hiki_disp(items[:cont])
|
151
|
-
end
|
152
|
-
|
153
|
-
def hiki_disp(lines)
|
154
|
-
lines.each{|line| puts "*#{line}"} if lines != nil
|
155
|
-
end
|
156
|
-
|
157
|
-
def disp_help(key_word)
|
158
|
-
print_separater
|
159
|
-
items =@help_cont[key_word]
|
160
|
-
puts items[:title].magenta
|
161
|
-
# puts CodeRay.scan("-#{items[:title]}:", :Taskpaper).term
|
162
|
-
disp(items[:cont])
|
163
|
-
print_separater
|
164
|
-
end
|
165
|
-
|
166
|
-
def disp(lines)
|
167
|
-
# lines.each{|line| puts " +#{line}"} if lines != nil
|
168
|
-
lines.each{|line| puts "*#{line}".blue}
|
169
|
-
# lines.each{|line| puts CodeRay.scan("+#{line}", :Taskpaper).term}
|
170
|
-
end
|
171
|
-
|
172
|
-
def print_separater
|
173
|
-
print "---\n"
|
174
|
-
end
|
175
|
-
|
176
|
-
=begin
|
177
|
-
def execute
|
178
|
-
puts "@execute\n"
|
179
|
-
if @argv.size==0
|
180
|
-
if @source_file.include?('todo')
|
181
|
-
@argv << '--all'
|
182
|
-
else
|
183
|
-
@argv << '--help'
|
184
|
-
end
|
185
|
-
end
|
186
|
-
=end
|
187
|
-
=begin
|
188
|
-
command_parser = OptionParser.new do |opt|
|
189
|
-
opt.on('-v', '--version','show program Version.') { |v|
|
190
|
-
opt.version = MyHelp::VERSION
|
191
|
-
puts opt.ver
|
192
|
-
}
|
193
|
-
|
194
|
-
|
195
|
-
@help_cont.each_pair{|key,val|
|
196
|
-
next if key==:head or key==:license
|
197
|
-
opts = val[:opts]
|
198
|
-
opt.on(opts[:short],opts[:long],opts[:desc]) {disp_help(key)}
|
199
|
-
}
|
200
|
-
=end
|
201
|
-
=begin
|
202
|
-
if ENV['LANG']=='C'
|
203
|
-
opt.on('--edit','edit help contents'){edit_help}
|
204
|
-
opt.on('--to_hiki','convert to hikidoc format'){to_hiki}
|
205
|
-
opt.on('--all','display all helps'){all_help}
|
206
|
-
opt.on('--store [item]','store [item] in backfile'){|item| store(item)}
|
207
|
-
opt.on('--remove [item]','remove [item] and store in backfile'){|item| remove(item) }
|
208
|
-
opt.on('--add [item]','add new [item]'){|item| add(item) }
|
209
|
-
opt.on('--backup_list [val]','show last [val] backup list'){|val| backup_list(val)}
|
210
|
-
else
|
211
|
-
opt.on('--edit','edit help contentsを開く'){edit_help}
|
212
|
-
opt.on('--to_hiki','hikiのformatに変更する'){to_hiki}
|
213
|
-
opt.on('--all','すべてのhelp画面を表示させる'){all_help}
|
214
|
-
opt.on('--store [item]','store [item] でback upをとる'){|item| store(item)}
|
215
|
-
opt.on('--remove [item]','remove [item] back upしてるlistを消去する'){|item| remove(item) }
|
216
|
-
opt.on('--add [item]','add new [item]で新しいhelpを作る'){|item| add(item) }
|
217
|
-
opt.on('--backup_list [val]','back upしているlistを表示させる'){|val| backup_list(val)}
|
218
|
-
end
|
219
|
-
=end
|
220
|
-
=begin
|
221
|
-
end
|
222
|
-
begin
|
223
|
-
command_parser.parse!(@argv)
|
224
|
-
rescue=> eval
|
225
|
-
p eval
|
226
|
-
end
|
227
|
-
=end
|
228
|
-
# exit
|
229
|
-
# end
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
data/lib/specific_help_opt.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require "optparse"
|
3
|
-
require "yaml"
|
4
|
-
require "my_help/version"
|
5
|
-
require 'fileutils'
|
6
|
-
require "coderay"
|
7
|
-
require 'colorize'
|
8
|
-
|
9
|
-
module SpecificHelpOpt
|
10
|
-
class Command
|
11
|
-
def self.run(file,argv=[])
|
12
|
-
new(file, argv).execute
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(file,argv=[])
|
16
|
-
@source_file = file
|
17
|
-
@help_cont = YAML.load(File.read(file))
|
18
|
-
# @help_cont[:head].each{|line| print line.chomp+"\n" } if @help_cont[:head] != nil
|
19
|
-
# @help_cont[:license].each{|line| print "#{line.chomp}\n" } if @help_cont[:license] != nil
|
20
|
-
@argv = argv
|
21
|
-
end
|
22
|
-
|
23
|
-
def execute
|
24
|
-
if @argv.size==0
|
25
|
-
if @source_file.include?('todo')
|
26
|
-
@argv << '--all'
|
27
|
-
else
|
28
|
-
@argv << '--help'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
command_parser = OptionParser.new do |opt|
|
33
|
-
opt.on('-v', '--version','show program Version.') { |v|
|
34
|
-
opt.version = MyHelp::VERSION
|
35
|
-
puts opt.ver
|
36
|
-
}
|
37
|
-
@help_cont.each_pair{|key,val|
|
38
|
-
next if key==:head or key==:license
|
39
|
-
opts = val[:opts]
|
40
|
-
opt.on(opts[:short],opts[:long],opts[:desc]) {disp_help(key)}
|
41
|
-
}
|
42
|
-
end
|
43
|
-
begin
|
44
|
-
command_parser.parse!(@argv)
|
45
|
-
rescue=> eval
|
46
|
-
p eval
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
def disp_help(key_word)
|
52
|
-
print_separater
|
53
|
-
items =@help_cont[key_word]
|
54
|
-
puts items[:title].magenta
|
55
|
-
# puts CodeRay.scan("-#{items[:title]}:", :Taskpaper).term
|
56
|
-
disp(items[:cont])
|
57
|
-
print_separater
|
58
|
-
end
|
59
|
-
|
60
|
-
def disp(lines)
|
61
|
-
# lines.each{|line| puts " +#{line}"} if lines != nil
|
62
|
-
lines.each{|line| puts "*#{line}".blue}
|
63
|
-
# lines.each{|line| puts CodeRay.scan("+#{line}", :Taskpaper).term}
|
64
|
-
end
|
65
|
-
|
66
|
-
def print_separater
|
67
|
-
print "---\n"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|