my_help 0.8.5 → 1.1a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/'../test'/.my_help/.my_help_conf.yml +2 -0
- data/'../test'/.my_help/emacs.org +50 -0
- data/{lib/templates → '../test'/.my_help}/org.org +0 -0
- data/{lib/templates → '../test'/.my_help}/todo.org +0 -0
- data/.gitignore +9 -1
- data/.my_help/example2.org +9 -0
- data/.rspec +1 -2
- data/.rspec_status +13 -0
- data/.yardoc/checksums +3 -3
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/Gemfile +10 -5
- data/Gemfile.lock +63 -56
- data/README.org +35 -29
- data/Rakefile +25 -14
- data/doc/MyHelp/Control.html +443 -221
- data/doc/MyHelp.html +7 -7
- data/doc/OrgToYaml.html +12 -10
- data/doc/_index.html +7 -7
- data/doc/class_list.html +2 -2
- data/doc/css/style.css +3 -2
- data/doc/file.README.html +29 -29
- data/doc/file_list.html +2 -2
- data/doc/frames.html +2 -2
- data/doc/index.html +29 -29
- data/doc/js/app.js +14 -3
- data/doc/method_list.html +24 -8
- data/doc/top-level-namespace.html +6 -6
- data/docs/README.html +218 -0
- data/docs/README.org +202 -0
- data/docs/old_docs/16b_nasu.pdf +0 -0
- data/docs/old_docs/17b_oyagi.pdf +0 -0
- data/docs/old_docs/19b_okabata.pdf +0 -0
- data/docs/old_docs/19b_yamaguchi.pdf +0 -0
- data/docs/old_docs/features/delete.feature +7 -0
- data/docs/old_docs/features/edit.feature +7 -0
- data/docs/old_docs/features/list.feature +6 -0
- data/docs/old_docs/features/new.feature +7 -0
- data/docs/old_docs/features/step_definitions/delete_spec.rb +12 -0
- data/docs/old_docs/features/step_definitions/edit_spec.rb +14 -0
- data/docs/old_docs/features/step_definitions/list_spec.rb +10 -0
- data/docs/old_docs/features/step_definitions/new_spec.rb +12 -0
- data/docs/old_docs/features/support/env.rb +3 -0
- data/docs/old_docs/fukumori_symp/18_human_interface_fukumori_workshop.pdf +0 -0
- data/docs/old_docs/fukumori_symp/memo_perp_magician.pdf +0 -0
- data/docs/old_docs/fukumori_symp//347/237/245/350/255/230/343/201/256/347/233/264/344/272/244/350/243/234/347/251/272/351/226/223.png +0 -0
- data/exe/my_help +1 -92
- data/lib/my_help/cli.rb +106 -0
- data/lib/my_help/config.rb +70 -0
- data/lib/my_help/git_cli.rb +40 -0
- data/lib/my_help/init.rb +28 -0
- data/lib/my_help/list.rb +76 -0
- data/lib/my_help/md2hash.rb +54 -0
- data/lib/my_help/modify.rb +33 -0
- data/lib/my_help/org2hash.rb +45 -0
- data/lib/my_help/org2yml.rb +15 -14
- data/lib/my_help/version.rb +3 -1
- data/lib/my_help.rb +23 -7
- data/lib/templates/emacs.org +13 -14
- data/lib/templates/example.md +17 -0
- data/lib/templates/example.org +9 -0
- data/my_help.gemspec +27 -24
- data/tmp.txt +14 -0
- metadata +52 -26
- data/README.html +0 -443
- data/README.rdoc +0 -6
- data/bin/my_help_thor +0 -66
- data/exe/my_help_gli +0 -82
- data/lib/my_help/my_help_controll.rb +0 -220
- data/lib/my_help/tomo_help_controll.rb +0 -0
- data/lib/templates/help_template.org +0 -8
data/lib/my_help/cli.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
module MyHelp
|
2
|
+
class CLI < Thor
|
3
|
+
include GetConfig
|
4
|
+
class_option :help_dir, :type => :string
|
5
|
+
# option :help_dir, :type => :string
|
6
|
+
# option :layer, :type => :numeric
|
7
|
+
|
8
|
+
# THOR to SILENCE DEPRECATION
|
9
|
+
# https://qiita.com/tbpgr/items/5edb1454634157ff816d
|
10
|
+
class << self
|
11
|
+
def exit_on_failure?
|
12
|
+
true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "version", "show version"
|
17
|
+
|
18
|
+
def version
|
19
|
+
puts VERSION
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "git [pull|push]", "git operations"
|
23
|
+
subcommand "git", Git
|
24
|
+
|
25
|
+
desc "init", "initialize my_help environment"
|
26
|
+
|
27
|
+
def init(*args)
|
28
|
+
config = get_config # for using methods in Config
|
29
|
+
#config.ask_default
|
30
|
+
init = Init.new(config)
|
31
|
+
raise "Local help dir exist." if init.help_dir_exist?
|
32
|
+
puts "Choose default markup '.org' [Y or .md]? "
|
33
|
+
response = $stdin.gets.chomp
|
34
|
+
config.configure(:ext => response) unless response.upcase[0] == "Y"
|
35
|
+
init.mk_help_dir
|
36
|
+
config.save_config
|
37
|
+
init.cp_templates
|
38
|
+
puts "If you want change editor use my_help set editor code."
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "set [:key] [VAL]", "set editor or ext"
|
42
|
+
|
43
|
+
def set(*args)
|
44
|
+
config = get_config # for using methods in Config
|
45
|
+
key = args[0] || ""
|
46
|
+
config.configure(key.to_sym => args[1])
|
47
|
+
config.save_config
|
48
|
+
conf_file_path = config[:conf_file]
|
49
|
+
puts "conf_file_path: %s" % conf_file_path
|
50
|
+
puts File.read(conf_file_path)
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "list [HELP] [ITEM]", "list helps"
|
54
|
+
# option :help_dir, :type => :string
|
55
|
+
option :layer, :type => :numeric
|
56
|
+
# use method_options [[https://github.com/rails/thor/wiki/Method-Options]]
|
57
|
+
def list(*args)
|
58
|
+
config = get_config
|
59
|
+
help_dir = options["help_dir"] || config[:local_help_dir]
|
60
|
+
layer = options["layer"] || 1
|
61
|
+
puts List.new(help_dir,
|
62
|
+
config[:ext],
|
63
|
+
layer).list(*args.join(" "))
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "edit [HELP]", "edit help"
|
67
|
+
|
68
|
+
def edit(*args)
|
69
|
+
c = get_config
|
70
|
+
help_name = args[0]
|
71
|
+
Modify.new(c).edit(help_name)
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "new [HELP]", "mk new HELP"
|
75
|
+
|
76
|
+
def new(*args)
|
77
|
+
c = get_config
|
78
|
+
help_name = args[0]
|
79
|
+
help_file = File.join(c[:local_help_dir], help_name + c[:ext])
|
80
|
+
Modify.new(c).new(help_file)
|
81
|
+
# puts res.stdout
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "delete [HELP]", "delete HELP"
|
85
|
+
|
86
|
+
def delete(*args)
|
87
|
+
c = get_config
|
88
|
+
help_name = args[0]
|
89
|
+
help_file = File.join(c[:local_help_dir], help_name + c[:ext])
|
90
|
+
puts "Are you sure to delete #{help_file}? [YN]"
|
91
|
+
responce = $stdin.gets.chomp
|
92
|
+
if responce.upcase[0] == "Y"
|
93
|
+
Modify.new(c).delete(help_file)
|
94
|
+
else
|
95
|
+
puts "Leave #{help_file} exists."
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
desc "hello", "hello"
|
100
|
+
|
101
|
+
def hello
|
102
|
+
name = $stdin.gets.chomp
|
103
|
+
puts("Hello #{name}.")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module MyHelp
|
2
|
+
|
3
|
+
# make @config from default and load yaml
|
4
|
+
# as shown
|
5
|
+
# https://stackoverflow.com/questions/6233124/where-to-place-access-config-file-in-gem
|
6
|
+
class Config
|
7
|
+
attr_reader :valid_config_keys
|
8
|
+
# Configuration defaults
|
9
|
+
def initialize(conf_path = nil)
|
10
|
+
conf_path ||= ENV["HOME"]
|
11
|
+
local_help_dir = File.join(conf_path, ".my_help")
|
12
|
+
@config = {
|
13
|
+
template_dir: File.expand_path("../templates", __dir__),
|
14
|
+
local_help_dir: local_help_dir,
|
15
|
+
conf_file: File.join(local_help_dir, ".my_help_conf.yml"),
|
16
|
+
editor: ENV["EDITOR"] || "emacs",
|
17
|
+
ext: ".org",
|
18
|
+
verbose: false,
|
19
|
+
}
|
20
|
+
@valid_config_keys = @config.keys
|
21
|
+
configure_with(@config[:conf_file])
|
22
|
+
# YAML.dump(@config, File.open(@config[:conf_file], 'w'))
|
23
|
+
# no good for multiple testers.
|
24
|
+
end
|
25
|
+
|
26
|
+
# Configure through hash
|
27
|
+
def configure(opts = nil)
|
28
|
+
return if opts == nil
|
29
|
+
opts.each do |k, v|
|
30
|
+
if @valid_config_keys.include? k.to_sym
|
31
|
+
@config[k.to_sym] = v
|
32
|
+
elsif k == "".to_sym
|
33
|
+
print "Valid key words are follows:"
|
34
|
+
p @valid_config_keys
|
35
|
+
else
|
36
|
+
raise KeyError.new("Error: keyword '#{k}' is invalid",
|
37
|
+
receiver: @config,
|
38
|
+
key: k)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
@config
|
42
|
+
end
|
43
|
+
|
44
|
+
# Configure through yaml file
|
45
|
+
def configure_with(path)
|
46
|
+
begin
|
47
|
+
config = YAML.safe_load(IO.read(path),
|
48
|
+
permitted_classes: [Symbol])
|
49
|
+
rescue Errno::ENOENT => e
|
50
|
+
message = "WARNING: #{e.message}.\nUsing default conf."
|
51
|
+
$stderr.puts message if @config[:verbose]
|
52
|
+
rescue Psych::SyntaxError => e
|
53
|
+
message = "WARNING: #{e.message}.\nUsing default conf."
|
54
|
+
$stderr.puts message if @config[:verbose]
|
55
|
+
end
|
56
|
+
configure(config)
|
57
|
+
end
|
58
|
+
|
59
|
+
# save config in @config[:conf_file]
|
60
|
+
def save_config()
|
61
|
+
File.write(@config[:conf_file], YAML.dump(config))
|
62
|
+
end
|
63
|
+
|
64
|
+
attr_reader :config
|
65
|
+
|
66
|
+
def [](sym)
|
67
|
+
@config[sym]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module MyHelp
|
2
|
+
module GetConfig
|
3
|
+
def get_config #(args)
|
4
|
+
parent_help_dir = options["help_dir"] || ""
|
5
|
+
parent_help_dir = ENV["HOME"] unless File.exist?(parent_help_dir)
|
6
|
+
return Config.new(parent_help_dir)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Git < Thor
|
11
|
+
include MyHelp::GetConfig
|
12
|
+
|
13
|
+
desc "pull", "pull my helps"
|
14
|
+
|
15
|
+
def pull
|
16
|
+
puts "called my_help git pull"
|
17
|
+
config = get_config
|
18
|
+
help_dir = config[:local_help_dir]
|
19
|
+
puts "on the target git directory : %s" % help_dir
|
20
|
+
Dir.chdir(help_dir) do
|
21
|
+
system "git pull origin main"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "push", "push my helps"
|
26
|
+
|
27
|
+
def push
|
28
|
+
puts "called my_help git push"
|
29
|
+
config = get_config
|
30
|
+
help_dir = config[:local_help_dir]
|
31
|
+
puts "on the target git directory : %s" % help_dir
|
32
|
+
Dir.chdir(help_dir) do
|
33
|
+
system "git add -A"
|
34
|
+
system "git commit -m 'auto commit from my_help'"
|
35
|
+
system "git pull origin main"
|
36
|
+
system "git push origin main"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/my_help/init.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module MyHelp
|
2
|
+
class Init
|
3
|
+
def initialize(config)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def help_dir_exist?
|
8
|
+
File.exist?(@config[:local_help_dir])
|
9
|
+
end
|
10
|
+
|
11
|
+
def check_conf_exist
|
12
|
+
File.exist?(@config[:conf_file])
|
13
|
+
end
|
14
|
+
|
15
|
+
def mk_help_dir
|
16
|
+
FileUtils.mkdir(@config[:local_help_dir])
|
17
|
+
end
|
18
|
+
|
19
|
+
def cp_templates
|
20
|
+
target_dir = @config[:local_help_dir]
|
21
|
+
src_dir = @config[:template_dir]
|
22
|
+
ext = @config[:ext]
|
23
|
+
Dir.glob(File.join(src_dir, "*#{ext}")).each do |file|
|
24
|
+
FileUtils.cp(file, target_dir, verbose: false)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/my_help/list.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require_relative "./org2yml"
|
2
|
+
#require "colorize"
|
3
|
+
require "colorized_string"
|
4
|
+
|
5
|
+
module MyHelp
|
6
|
+
# Your code goes here...
|
7
|
+
class List
|
8
|
+
def initialize(path = "", ext = ".org", layer = 1)
|
9
|
+
@path = path
|
10
|
+
@ext = ext
|
11
|
+
p @layer = layer
|
12
|
+
end
|
13
|
+
|
14
|
+
def list(help_options = "", level = 0)
|
15
|
+
name, item = help_options.split(" ")
|
16
|
+
if item == nil && name == nil
|
17
|
+
list_helps()
|
18
|
+
else
|
19
|
+
path = File.exists?(name + @ext) ? name + @ext :
|
20
|
+
File.join(@path, name + @ext)
|
21
|
+
list_help_with(path, name, item)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def read_help(file)
|
26
|
+
info = {}
|
27
|
+
info[:items] = Org2Hash.new(File.read(file)).contents
|
28
|
+
info[:name] = File.basename(file).split(".")[0]
|
29
|
+
return info
|
30
|
+
end
|
31
|
+
|
32
|
+
def list_helps()
|
33
|
+
files = File.join(@path, "*#{@ext}")
|
34
|
+
Dir.glob(files).inject("") do |out, file|
|
35
|
+
# p [out, file]
|
36
|
+
help_info = read_help(file)
|
37
|
+
out << "%10s: %s\n" % [help_info[:name],
|
38
|
+
help_info[:items]["head"].split("\n")[0]]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# defaultで@path/name.@extのヘルプを読み込んで,itemを表示
|
43
|
+
#
|
44
|
+
def list_help_with(path, name, item)
|
45
|
+
@help_info = read_help(path)
|
46
|
+
output = ColorizedString["my_help called with name : #{name}, item : #{item}\n"].colorize(:cyan)
|
47
|
+
|
48
|
+
if item == nil
|
49
|
+
@help_info[:items].each_pair do |item, val|
|
50
|
+
item, desc = item.split(":")
|
51
|
+
desc ||= ""
|
52
|
+
output << "- %20s : %s\n" % [item, desc]
|
53
|
+
end
|
54
|
+
else
|
55
|
+
output << find_near(item)
|
56
|
+
end
|
57
|
+
return output
|
58
|
+
end
|
59
|
+
|
60
|
+
def find_near(input_item)
|
61
|
+
candidates = []
|
62
|
+
@help_info[:items].each_pair do |item, val|
|
63
|
+
candidates << item if item.include?(input_item)
|
64
|
+
end
|
65
|
+
if candidates.size == 0
|
66
|
+
"Can't find similar item name with : #{input_item}"
|
67
|
+
else
|
68
|
+
contents = candidates.collect do |near_item|
|
69
|
+
ColorizedString["item : #{near_item} \n"].colorize(:cyan) +
|
70
|
+
@help_info[:items][near_item]
|
71
|
+
end
|
72
|
+
contents.join("\n")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module MyHelp
|
2
|
+
class Md2Hash
|
3
|
+
attr_accessor :md_text, :contents, :results, :opts
|
4
|
+
|
5
|
+
def initialize(md_text = "", **opts)
|
6
|
+
@opts = opts
|
7
|
+
@md_text = md_text.split("\n")
|
8
|
+
@contents = fsm
|
9
|
+
#fsm()
|
10
|
+
end
|
11
|
+
|
12
|
+
TRANS = {
|
13
|
+
#current
|
14
|
+
# new action
|
15
|
+
#-----------------------------------
|
16
|
+
init: {
|
17
|
+
#"*" => [:init, :ignore],
|
18
|
+
:default => [:init, :ignore],
|
19
|
+
"#" => [:reading, :item],
|
20
|
+
},
|
21
|
+
reading: {
|
22
|
+
"#" => [:reading, :item],
|
23
|
+
:default => [:reading, :data],
|
24
|
+
},
|
25
|
+
}
|
26
|
+
|
27
|
+
def fsm
|
28
|
+
contents = {}
|
29
|
+
state = :init
|
30
|
+
@results = []
|
31
|
+
item = ""
|
32
|
+
@md_text.each do |line|
|
33
|
+
state, action = TRANS[state][line[0]] || TRANS[state][:default]
|
34
|
+
|
35
|
+
if line[0..1] == "#+" # line[1] != " "
|
36
|
+
state = :init
|
37
|
+
action = :ignore
|
38
|
+
end
|
39
|
+
|
40
|
+
results << [line, state, action]
|
41
|
+
|
42
|
+
case action
|
43
|
+
when :ignore
|
44
|
+
when :item
|
45
|
+
item = line.match(/^# (.+)/)[1]
|
46
|
+
contents[item] = []
|
47
|
+
when :data
|
48
|
+
contents[item] << line
|
49
|
+
end
|
50
|
+
end
|
51
|
+
return contents
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module MyHelp
|
2
|
+
class Modify
|
3
|
+
def initialize(conf)
|
4
|
+
@conf = conf
|
5
|
+
end
|
6
|
+
|
7
|
+
def new(help_file)
|
8
|
+
target = help_file
|
9
|
+
source = File.join(@conf[:template_dir], "example.org")
|
10
|
+
FileUtils.cp(source, target, verbose: @conf[:verbose])
|
11
|
+
end
|
12
|
+
|
13
|
+
def delete(help_file)
|
14
|
+
if File.exist?(help_file)
|
15
|
+
FileUtils.rm(help_file, verbose: @conf[:verbose])
|
16
|
+
else
|
17
|
+
puts "file #{help_file} does not exist."
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit(help_name)
|
22
|
+
p help_file = File.join(@conf[:local_help_dir],
|
23
|
+
help_name + @conf[:ext])
|
24
|
+
if File.exist?(help_file)
|
25
|
+
p comm = "#{@conf[:editor]} #{help_file}"
|
26
|
+
system(comm)
|
27
|
+
else
|
28
|
+
puts "file #{help_file} does not exist,"
|
29
|
+
puts "make #{help_name} first by 'new' command."
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module MyHelp
|
2
|
+
# get org and trans it to hash by FSM
|
3
|
+
class Org2Hash
|
4
|
+
attr_accessor :contents, :text
|
5
|
+
# current_state => [ new_state, action ]
|
6
|
+
TRANSITIONS = {
|
7
|
+
:header_read => {
|
8
|
+
"* " => [:contents_read, :start_new_item],
|
9
|
+
:default => [:header_read, :ignore],
|
10
|
+
},
|
11
|
+
:contents_read => {
|
12
|
+
"* " => [:contents_read, :start_new_item],
|
13
|
+
:default => [:contents_read, :add_contents],
|
14
|
+
},
|
15
|
+
}
|
16
|
+
|
17
|
+
def initialize(org_text)
|
18
|
+
@text = org_text
|
19
|
+
@contents = Hash.new
|
20
|
+
simple_fsm()
|
21
|
+
end
|
22
|
+
|
23
|
+
def simple_fsm()
|
24
|
+
state = :header_read
|
25
|
+
item = ""
|
26
|
+
@text.split("\n").each do |line|
|
27
|
+
next if line.size < 1
|
28
|
+
state, action = TRANSITIONS[state][line[0..1]] ||
|
29
|
+
TRANSITIONS[state][:default]
|
30
|
+
case action
|
31
|
+
when :ignore
|
32
|
+
when :start_new_item
|
33
|
+
item = read_item(line)
|
34
|
+
@contents[item] = ""
|
35
|
+
when :add_contents
|
36
|
+
@contents[item] += line + "\n"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def read_item(line)
|
42
|
+
line.match(/\* (.+)/)[1]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/my_help/org2yml.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "yaml"
|
3
|
+
require "pp"
|
4
4
|
|
5
|
-
class
|
5
|
+
class Org2Yaml
|
6
6
|
attr_accessor :help_cont
|
7
7
|
|
8
8
|
def initialize(file)
|
9
9
|
@help_cont = {} #{ head: [File.basename(file, '.org')] }
|
10
10
|
@head_sym = nil
|
11
|
-
@conts =
|
11
|
+
@conts = ""
|
12
12
|
@short_stored = []
|
13
13
|
org_to_yaml(File.readlines(file))
|
14
14
|
end
|
15
15
|
|
16
16
|
def make_options(line)
|
17
|
-
head, desc = line.split(
|
17
|
+
head, desc = line.split(":")
|
18
18
|
desc ||= head.to_s
|
19
19
|
short = "-#{head[0]}"
|
20
|
-
if @short_stored.include?(short) or head==
|
21
|
-
short =
|
20
|
+
if @short_stored.include?(short) or head == "license" or head == "head"
|
21
|
+
short = ""
|
22
22
|
else
|
23
23
|
@short_stored << short
|
24
24
|
end
|
@@ -27,27 +27,28 @@ class OrgToYaml
|
|
27
27
|
|
28
28
|
def next_cont(head)
|
29
29
|
@help_cont[@head_sym][:cont] = @conts if @head_sym
|
30
|
-
return if head ==
|
31
|
-
@conts =
|
30
|
+
return if head == "EOF"
|
31
|
+
@conts = ""
|
32
32
|
@head_sym = head.to_sym
|
33
33
|
@help_cont[@head_sym] = {
|
34
|
-
opts: make_options(head), title: head, cont:
|
34
|
+
opts: make_options(head), title: head, cont: "",
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
38
38
|
def org_to_yaml(lines)
|
39
39
|
lines.each do |line|
|
40
|
-
|
41
|
-
|
40
|
+
m = line.force_encoding(Encoding::UTF_8).match(/^(\*+) (.+)/u)
|
41
|
+
if m
|
42
|
+
next_cont m[2]
|
42
43
|
else
|
43
44
|
@conts << line
|
44
45
|
end
|
45
46
|
end
|
46
|
-
next_cont
|
47
|
+
next_cont "EOF"
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
if $PROGRAM_NAME == __FILE__
|
51
|
+
if $PROGRAM_NAME == __FILE__
|
51
52
|
helps = OrgToYaml.new(ARGV[0])
|
52
53
|
pp helps.help_cont
|
53
54
|
end
|
data/lib/my_help/version.rb
CHANGED
data/lib/my_help.rb
CHANGED
@@ -1,7 +1,23 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
|
7
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "thor"
|
3
|
+
require "fileutils"
|
4
|
+
require "pp"
|
5
|
+
require "yaml"
|
6
|
+
require "command_line/global"
|
7
|
+
|
8
|
+
require_relative "my_help/version"
|
9
|
+
require_relative "my_help/list"
|
10
|
+
require_relative "my_help/config"
|
11
|
+
require_relative "my_help/modify"
|
12
|
+
require_relative "my_help/init"
|
13
|
+
require_relative "my_help/git_cli"
|
14
|
+
require_relative "my_help/cli"
|
15
|
+
require_relative "my_help/org2hash"
|
16
|
+
require_relative "my_help/md2hash"
|
17
|
+
|
18
|
+
module MyHelp
|
19
|
+
class Error < StandardError; end
|
20
|
+
|
21
|
+
# Your code goes here...
|
22
|
+
|
23
|
+
end
|
data/lib/templates/emacs.org
CHANGED
@@ -1,33 +1,32 @@
|
|
1
|
-
#+STARTUP: indent nolineimages
|
1
|
+
#+STARTUP: indent nolineimages overview
|
2
2
|
* head
|
3
3
|
- Emacs key bind
|
4
|
-
-
|
5
|
-
|
6
|
-
-
|
7
|
-
-
|
8
|
-
- c-
|
9
|
-
- c-x u, Undo operation(Undo)
|
4
|
+
- special key command
|
5
|
+
- c-f, While pressing the control key, press 'f'
|
6
|
+
- M-f, After pressing Esc key, press 'f'
|
7
|
+
- c-g, Operation interruption
|
8
|
+
- c-x u, Undo operation(Undo)
|
10
9
|
* license
|
11
10
|
- cc by Natsuko Kawabata, 2017
|
12
11
|
|
13
|
-
*
|
12
|
+
* cursor_move
|
14
13
|
- c-f, move Forward, Move to forward or right
|
15
14
|
- c-b, move Backward, Move to back or left
|
16
15
|
- c-a, go Ahead of line, Move to the beginning of the line
|
17
16
|
- c-e, go End of line, Move to the end of the line
|
18
17
|
- c-n, move Next line, Move to next line
|
19
18
|
- c-p, move Previous line, Move to previous line
|
20
|
-
*
|
19
|
+
* page_move
|
21
20
|
- c-v, move Vertical, Move to next page
|
22
21
|
- M-v, move reversive Vertical,Move to previous page
|
23
22
|
- c-l, centerise Line, Move to center on current line
|
24
23
|
- M-<, move Top of file, Move to the top of the file
|
25
24
|
- M->, move Bottom of file, Move to the end of the file
|
26
|
-
*
|
25
|
+
* file_operation
|
27
26
|
- c-x c-f, Find file, Find file
|
28
27
|
- c-x c-s, Save file, Save file
|
29
28
|
- c-x c-w, Write file NAME, Write a file with another name
|
30
|
-
*
|
29
|
+
* edit_operation
|
31
30
|
- c-d, Delete char, Delete a letter
|
32
31
|
- c-k, Kill line, Delete a line,cut
|
33
32
|
- c-y, Yank, Paste
|
@@ -36,15 +35,15 @@ special key command
|
|
36
35
|
- c-s, forward incremental Search WORD, 前へ WORD を検索
|
37
36
|
- c-r, Reverse incremental search WORD, 後へ WORD を検索
|
38
37
|
- M-x query-replace WORD1 <ret> WORD2:対話的置換(y or n で可否選択)
|
39
|
-
*
|
38
|
+
* window_operation
|
40
39
|
- c-x 2, 2 windows, Split into two windows 二つに分割
|
41
40
|
- c-x 1, 1 windows, Integrate in a window
|
42
41
|
- c-x 3, 3rd window sep, Split vertically
|
43
42
|
- c-x o, Other windows, Move to the next window
|
44
|
-
*
|
43
|
+
* buffer_operation
|
45
44
|
- すでに open して Emacs にバッファーされた file
|
46
45
|
- c-x b, show Buffer, Buffer list
|
47
46
|
- c-x c-b, next Buffer, Move to next buffer
|
48
|
-
*
|
47
|
+
* quit_operation
|
49
48
|
- c-x c-c, Quit Emacs, Save file and quit
|
50
49
|
- c-z, suspend Emacs, Pause,restart with fg
|