my_help 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/Gemfile.lock +1 -1
  4. data/README.org +3 -3
  5. data/lib/my_help/my_help_controll.rb +20 -15
  6. data/lib/my_help/version.rb +1 -1
  7. data/{before_gli/lib/templates/emacs_help.org → lib/templates/emacs.org} +0 -0
  8. data/{before_gli/lib/templates/template_help.org → lib/templates/help_template.org} +0 -0
  9. data/{before_gli/lib/templates/org_help.org → lib/templates/org.org} +0 -0
  10. data/{before_gli/lib/templates/my_todo.org → lib/templates/todo.org} +2 -2
  11. metadata +6 -38
  12. data/before_gli/Dockerfile.template +0 -13
  13. data/before_gli/Gemfile +0 -5
  14. data/before_gli/Gemfile.lock +0 -63
  15. data/before_gli/bin/console +0 -14
  16. data/before_gli/bin/setup +0 -8
  17. data/before_gli/exe/e_h +0 -4
  18. data/before_gli/exe/emacs_help +0 -4
  19. data/before_gli/exe/m_t +0 -4
  20. data/before_gli/exe/my_help +0 -6
  21. data/before_gli/exe/my_todo +0 -4
  22. data/before_gli/exe/o_h +0 -4
  23. data/before_gli/exe/org_help +0 -4
  24. data/before_gli/lib/emacs_help.rb +0 -137
  25. data/before_gli/lib/my_help/my_help_controll.rb +0 -134
  26. data/before_gli/lib/my_help/org2yml.rb +0 -47
  27. data/before_gli/lib/my_help/specific_help.rb +0 -2
  28. data/before_gli/lib/my_help/test.rb +0 -29
  29. data/before_gli/lib/my_help/version.rb +0 -3
  30. data/before_gli/lib/my_help/yml2org.rb +0 -34
  31. data/before_gli/lib/my_help.rb +0 -204
  32. data/before_gli/lib/my_help_new.rb +0 -54
  33. data/before_gli/lib/my_help_thor.rb +0 -170
  34. data/before_gli/lib/specific_help.rb +0 -172
  35. data/before_gli/lib/specific_help_bu.rb +0 -233
  36. data/before_gli/lib/specific_help_opt.rb +0 -71
  37. data/before_gli/lib/specific_help_thor.rb +0 -172
  38. data/before_gli/make_docker.sh +0 -5
  39. data/before_gli/my_help.gemspec +0 -34
  40. data/lib/templates/emacs_help.org +0 -50
  41. data/lib/templates/my_todo.org +0 -11
  42. data/lib/templates/org_help.org +0 -64
  43. data/lib/templates/template_help.org +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 329496bbae92a57e90f94b719ddd2be82e2ef5d3
4
- data.tar.gz: 813ed1f72d37fa2d93c529ed7eea68340373d1ca
3
+ metadata.gz: 2acf848b3e98662747f041251d65751f61991ab6
4
+ data.tar.gz: 96ddb81c7b0a6cc3baff1dc0f1bf866966d5d06c
5
5
  SHA512:
6
- metadata.gz: ec29d078e2e359b1b207359f83eb1ee2bcc844fab35995f97e3c42936904cd31f71e33f0ef9ff16603f6fe205c6bb160a03f4caa5e33f2a705a77bf1175bf602
7
- data.tar.gz: 994d20e42858e1df0192f6b91efc8df0c3f5da0b037c961e4065824ac0d35d6eeef6cf66c5d542ff2867a4dcc67a3e6daa5c86cbd0a899441bddfb5168506d9b
6
+ metadata.gz: a7ced46cde76b762d5bd7ade8cd53ae5f0dd83b038bab5e9b5bdf57827198bbf192a919cec9acbb94a8eef5fb38bed05aef3fc3ea56459ef9f4c5c79d2a615f8
7
+ data.tar.gz: b137ed36475e5338fd83fb992e869e7422ca8f0b35565ab5bb490cb81bb70a83978eac46fbfd88c84966bcd6ed6aa6dbbb8ca7d211ee447817742a10255c31ad
data/.gitignore CHANGED
@@ -6,6 +6,5 @@
6
6
  /pkg/
7
7
  *~
8
8
  \#*
9
- /before_gli/
10
- Dockerfile
9
+
11
10
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_help (0.0.1)
4
+ my_help (0.7.1)
5
5
  colorize
6
6
  gli (= 2.17.1)
7
7
 
data/README.org CHANGED
@@ -90,9 +90,9 @@ COMMANDS
90
90
  としてください.このlistにargsやitemを加えて行くとわかると思います.
91
91
 
92
92
  : my_help list
93
- : my_help list emacs_help
94
- : my_help list emacs_help -f
95
- : my_help list emacs_help file
93
+ : my_help list emacs
94
+ : my_help list emacs -f
95
+ : my_help list emacs file
96
96
  として動かしてみてください.
97
97
 
98
98
 
@@ -11,7 +11,7 @@ module MyHelp
11
11
  return if File::exists?(@local_help_dir)
12
12
  FileUtils.mkdir_p(@local_help_dir, :verbose=>true)
13
13
  Dir.entries(@template_dir).each{|file|
14
- next if file=='template_help.org'
14
+ next if file=='help_template.org'
15
15
  file_path=File.join(@local_help_dir,file)
16
16
  next if File::exists?(file_path)
17
17
  FileUtils.cp((File.join(@template_dir,file)),@local_help_dir,:verbose=>true)
@@ -69,16 +69,19 @@ module MyHelp
69
69
  help = auto_load(file_path)
70
70
  next if help.nil?
71
71
  desc = help[:head][:cont].split("\n")[0]
72
- print " #{title}\t: #{desc}\n".blue
72
+ print title.rjust(10).blue
73
+ print ": #{desc}\n".blue
73
74
  end
74
75
  end
75
76
 
76
77
  def edit_help(file)
77
- target_help = File.join(@local_help_dir,file)
78
- ['.yml','.org'].each do |ext|
79
- p target_help += ext if local_help_entries.member?(file+ext)
78
+ target_help = File.join(@local_help_dir,file+'.org')
79
+ if local_help_entries.member?(target_help)
80
+ system "emacs #{target_help}"
81
+ else
82
+ puts "file #{target_help} does not exits in #{@local_help_dir}."
83
+ puts "init #{file} first."
80
84
  end
81
- system "emacs #{target_help}"
82
85
  end
83
86
 
84
87
  def init_help(file)
@@ -88,10 +91,10 @@ module MyHelp
88
91
  end
89
92
  p target_help=File.join(@local_help_dir,file+'.org')
90
93
  if File::exists?(target_help)
91
- puts "File exists. --delete it first to initialize it."
94
+ puts "File exists. delete it first to initialize it."
92
95
  exit
93
96
  end
94
- p template = File.join(@template_dir,'template_help.org')
97
+ p template = File.join(@template_dir,'help_template.org')
95
98
  FileUtils::Verbose.cp(template,target_help)
96
99
  end
97
100
 
@@ -113,19 +116,21 @@ module MyHelp
113
116
  def local_help_entries
114
117
  entries= []
115
118
  Dir.entries(@local_help_dir).each{|file|
116
- next unless file.include?('_')
117
- next if file[0]=='#' or file[-1]=='~' or file[0]=='.'
118
- next if file.match(/(.+)_e\.org/) # OK?
119
- next if file.match(/(.+)\.html/)
120
- entries << file
119
+ # next unless file.include?('_')
120
+ # next if file[0]=='#' or file[-1]=='~' or file[0]=='.'
121
+ # next if file.match(/(.+)_e\.org/) # OK?
122
+ # next if file.match(/(.+)\.html/)
123
+ if file.match(/(.+)\.org$/) # OK?
124
+ entries << file
125
+ end
121
126
  }
122
127
  return entries
123
128
  end
124
129
 
125
130
  def auto_load(file_path)
126
131
  case File.extname(file_path)
127
- when '.yml'
128
- cont = YAML.load(File.read(file_path))
132
+ # when '.yml'
133
+ # cont = YAML.load(File.read(file_path))
129
134
  when '.org'
130
135
  cont = OrgToYaml.new(file_path).help_cont
131
136
  else
@@ -1,3 +1,3 @@
1
1
  module MyHelp
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
@@ -3,9 +3,9 @@
3
3
  - my todo
4
4
  * license
5
5
  - cc by Shigeto R. Nishitani, 2016
6
- * daily(今日のtodo)
6
+ * daily
7
7
  - ご飯を食べる
8
8
  - 10時には寝床へ入る
9
- * weekly(週間todo)
9
+ * weekly
10
10
  - 毎日8時間寝る
11
11
  - 毎朝ちゃんと食べる
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_help
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Your Name Here
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-30 00:00:00.000000000 Z
11
+ date: 2018-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -102,47 +102,15 @@ files:
102
102
  - README_en.org
103
103
  - Rakefile
104
104
  - Rakefile_gli
105
- - before_gli/Dockerfile.template
106
- - before_gli/Gemfile
107
- - before_gli/Gemfile.lock
108
- - before_gli/bin/console
109
- - before_gli/bin/setup
110
- - before_gli/exe/e_h
111
- - before_gli/exe/emacs_help
112
- - before_gli/exe/m_t
113
- - before_gli/exe/my_help
114
- - before_gli/exe/my_todo
115
- - before_gli/exe/o_h
116
- - before_gli/exe/org_help
117
- - before_gli/lib/emacs_help.rb
118
- - before_gli/lib/my_help.rb
119
- - before_gli/lib/my_help/my_help_controll.rb
120
- - before_gli/lib/my_help/org2yml.rb
121
- - before_gli/lib/my_help/specific_help.rb
122
- - before_gli/lib/my_help/test.rb
123
- - before_gli/lib/my_help/version.rb
124
- - before_gli/lib/my_help/yml2org.rb
125
- - before_gli/lib/my_help_new.rb
126
- - before_gli/lib/my_help_thor.rb
127
- - before_gli/lib/specific_help.rb
128
- - before_gli/lib/specific_help_bu.rb
129
- - before_gli/lib/specific_help_opt.rb
130
- - before_gli/lib/specific_help_thor.rb
131
- - before_gli/lib/templates/emacs_help.org
132
- - before_gli/lib/templates/my_todo.org
133
- - before_gli/lib/templates/org_help.org
134
- - before_gli/lib/templates/template_help.org
135
- - before_gli/make_docker.sh
136
- - before_gli/my_help.gemspec
137
105
  - bin/my_help
138
106
  - lib/my_help.rb
139
107
  - lib/my_help/my_help_controll.rb
140
108
  - lib/my_help/org2yml.rb
141
109
  - lib/my_help/version.rb
142
- - lib/templates/emacs_help.org
143
- - lib/templates/my_todo.org
144
- - lib/templates/org_help.org
145
- - lib/templates/template_help.org
110
+ - lib/templates/emacs.org
111
+ - lib/templates/help_template.org
112
+ - lib/templates/org.org
113
+ - lib/templates/todo.org
146
114
  - my_help.gemspec
147
115
  - my_help.rdoc
148
116
  homepage: http://your.website.com
@@ -1,13 +0,0 @@
1
- FROM alpine:3.7
2
-
3
- RUN apk update && apk upgrade
4
- RUN apk --update add \
5
- openssh git build-base libffi libffi-dev \
6
- ruby ruby-dev ruby-rake ruby-bundler
7
-
8
- # RUN git clone https://github.com/daddygongon/my_help.git
9
- COPY . ~/my_help
10
- WORKDIR ~/my_help
11
-
12
- RUN bundle update
13
- RUN bundle exec exe/my_help -m && rake install:local
data/before_gli/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in my_help.gemspec
4
- gemspec
5
- gem 'aruba', '~> 0.14.2'
@@ -1,63 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- my_help (0.6.2)
5
- colorize
6
- systemu
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- aruba (0.14.5)
12
- childprocess (>= 0.6.3, < 0.10.0)
13
- contracts (~> 0.9)
14
- cucumber (>= 1.3.19)
15
- ffi (~> 1.9.10)
16
- rspec-expectations (>= 2.99)
17
- thor (~> 0.19)
18
- backports (3.11.1)
19
- builder (3.2.3)
20
- childprocess (0.9.0)
21
- ffi (~> 1.0, >= 1.0.11)
22
- colorize (0.8.1)
23
- contracts (0.16.0)
24
- cucumber (3.1.0)
25
- builder (>= 2.1.2)
26
- cucumber-core (~> 3.1.0)
27
- cucumber-expressions (~> 5.0.4)
28
- cucumber-wire (~> 0.0.1)
29
- diff-lcs (~> 1.3)
30
- gherkin (~> 5.0)
31
- multi_json (>= 1.7.5, < 2.0)
32
- multi_test (>= 0.1.2)
33
- cucumber-core (3.1.0)
34
- backports (>= 3.8.0)
35
- cucumber-tag_expressions (~> 1.1.0)
36
- gherkin (>= 5.0.0)
37
- cucumber-expressions (5.0.13)
38
- cucumber-tag_expressions (1.1.1)
39
- cucumber-wire (0.0.1)
40
- diff-lcs (1.3)
41
- ffi (1.9.23)
42
- gherkin (5.0.0)
43
- multi_json (1.13.1)
44
- multi_test (0.1.2)
45
- rake (10.5.0)
46
- rspec-expectations (3.7.0)
47
- diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.7.0)
49
- rspec-support (3.7.1)
50
- systemu (2.6.5)
51
- thor (0.20.0)
52
-
53
- PLATFORMS
54
- ruby
55
-
56
- DEPENDENCIES
57
- aruba (~> 0.14.2)
58
- bundler (~> 1.11)
59
- my_help!
60
- rake (~> 10.0)
61
-
62
- BUNDLED WITH
63
- 1.16.1
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "my_help"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/before_gli/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/before_gli/exe/e_h DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'specific_help'
3
- help_file = File.join(ENV['HOME'],'.my_help','emacs_help.org')
4
- SpecificHelp::Command.run(help_file, ARGV)
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'specific_help'
3
- help_file = File.join(ENV['HOME'],'.my_help','emacs_help.org')
4
- SpecificHelp::Command.run(help_file, ARGV)
data/before_gli/exe/m_t DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'specific_help'
3
- help_file = File.join(ENV['HOME'],'.my_help','my_todo.org')
4
- SpecificHelp::Command.run(help_file, ARGV)
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require "my_help_new"
3
- MyHelp::Command.run(ARGV)
4
-
5
- #require "my_help_thor"
6
- #MyHelp::Command.start(ARGV)
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'specific_help'
3
- help_file = File.join(ENV['HOME'],'.my_help','my_todo.org')
4
- SpecificHelp::Command.run(help_file, ARGV)
data/before_gli/exe/o_h DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'specific_help'
3
- help_file = File.join(ENV['HOME'],'.my_help','org_help.org')
4
- SpecificHelp::Command.run(help_file, ARGV)
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'specific_help'
3
- help_file = File.join(ENV['HOME'],'.my_help','org_help.org')
4
- SpecificHelp::Command.run(help_file, ARGV)
@@ -1,137 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require "optparse"
3
- require "emacs_help/version"
4
-
5
- module EmacsHelp
6
- class Command
7
- def self.run(argv=[])
8
- print "\n特殊キー操作"
9
- print "\tc-f, controlキーを押しながら 'f'\n"
10
- print "\t\tM-f, escキーを押した後一度離して'f'\n"
11
- print "\t操作の中断c-g, 操作の取り消し(Undo) c-x u \n"
12
- new(argv).execute
13
- end
14
-
15
- def initialize(argv=[])
16
- @argv = argv
17
- data_path = File.join(ENV['HOME'], '.hikirc')
18
- end
19
-
20
- def execute
21
- @argv << '--help' if @argv.size==0
22
- command_parser = OptionParser.new do |opt|
23
- opt.on('-v', '--version','show program Version.') { |v|
24
- opt.version = EmacsHelp::VERSION
25
- puts opt.ver
26
- }
27
- opt.on('-c','--カーソル','Cursor移動') {cursor_move}
28
- opt.on('-p','--ページ','Page移動') {page_move}
29
- opt.on('-f','--ファイル','File操作') {file}
30
- opt.on('-e','--編集','Edit操作') {edit}
31
- opt.on('-w','--ウィンドウ','Window操作') {window}
32
- opt.on('-b','--バッファ','Buffer操作') {buffer}
33
- opt.on('-q','--終了','終了操作') {quit}
34
- opt.on('--edit','edit help contents'){edit_help}
35
- opt.on('--edit','edit help contentsを開く'){edit_help}
36
- # opt.on('--to_hiki','convert to hikidoc format'){to_hiki}
37
- opt.on('--to_hiki','hikiのformatに変更する'){to_hiki}
38
- # opt.on('--all','display all helps'){all_help}
39
- opt.on('--all','すべてのhelp画面を表示させる'){all_help}
40
- # opt.on('--store [item]','store [item] in backfile'){|item| store(item)}
41
- opt.on('--store [item]','store [item] でback upをとる'){|item| store(item)}
42
- # opt.on('--remove [item]','remove [item] and store in backfile'){|item| remove(item) }
43
- opt.on('--remove [item]','remove [item] back upしてるlistを消去する'){|item| remove(item) }
44
- # opt.on('--add [item]','add new [item]'){|item| add(item) }
45
- opt.on('--add [item]','add new [item]で新しいhelpを作る'){|item| add(item) }
46
- # opt.on('--backup_list [val]','show last [val] backup list'){|val| backup_list(val)}
47
- opt.on('--backup_list [val]','back upしているlistを表示させる'){|val| backup_list(val)}
48
-
49
- end
50
- begin
51
- command_parser.parse!(@argv)
52
- rescue=> eval
53
- p eval
54
- end
55
- exit
56
- end
57
-
58
- def disp(lines)
59
- lines.each{|line|
60
- if line.include?(',')
61
- show line
62
- else
63
- puts " #{line}"
64
- end
65
- }
66
- end
67
- def show(line)
68
- puts " #{line}"
69
- end
70
-
71
- def quit
72
- puts "\n終了操作quit"
73
- cont = ["c-x c-c, Quit emacs, ファイルを保存して終了",
74
- "c-z, suspend emacs, 一時停止,fgで復活"]
75
- disp(cont)
76
- end
77
-
78
- def window
79
- puts "\nウィンドウ操作window"
80
- cont=["c-x 2, 2 windows, 二つに分割",
81
- "c-x 1, 1 windows, 一つに戻す",
82
- "c-x 3, 3rd window sep,縦線分割",
83
- "c-x o, Other windows, 次の画面へ移動"]
84
- disp(cont)
85
- end
86
-
87
- def buffer
88
- puts "\nバッファー操作buffer"
89
- cont =[ "c-x b, show Buffer, バッファのリスト",
90
- "c-x c-b, next Buffer, 次のバッファへ移動"]
91
- disp(cont)
92
- end
93
-
94
- def edit
95
- puts "\n編集操作editor"
96
- cont = ["c-d, Delete char, 一字削除",
97
- "c-k, Kill line, 一行抹消,カット",
98
- "c-y, Yank, ペースト",
99
- "c-w, Kill region, 領域抹消,カット",
100
- "領域選択は,先頭or最後尾でc-spaceした後,最後尾or先頭へカーソル移動",
101
- "c-s, forward incremental Search WORD, 前へWORDを検索",
102
- "c-r, Reverse incremental search WORD, 後へWORDを検索",
103
- "M-x query-replace WORD1 <ret> WORD2:対話的置換(y or nで可否選択)"]
104
- disp(cont)
105
- end
106
-
107
- def file
108
- puts "\nファイル操作file"
109
- cont =[ "c-x c-f, Find file, ファイルを開く",
110
- "c-x c-s, Save file, ファイルを保存",
111
- "c-x c-w, Write file NAME, ファイルを別名で書き込む"]
112
- disp(cont)
113
- end
114
-
115
- def page_move
116
- puts "\nページ移動page"
117
- cont = ["c-v, move Vertical, 次のページへ",
118
- "M-v, move reversive Vertical,前のページへ",
119
- "c-l, centerise Line, 現在行を中心に",
120
- "M-<, move Top of file, ファイルの先頭へ",
121
- "M->, move Bottom of file, ファイルの最後尾へ"]
122
- disp(cont)
123
- end
124
-
125
- def cursor_move
126
- puts "\nカーソル移動cursor"
127
- cont = ["c-f, move Forwrard, 前or右へ",
128
- "c-b, move Backwrard, 後or左へ",
129
- "c-a, go Ahead of line, 行頭へ",
130
- "c-e, go End of line, 行末へ",
131
- "c-n, move Next line, 次行へ",
132
- "c-p, move Previous line, 前行へ"]
133
- disp(cont)
134
- end
135
-
136
- end
137
- end
@@ -1,134 +0,0 @@
1
- module MyHelp
2
- class Control
3
- def initialize(argv)
4
- @argv = argv
5
- @template_dir = File.expand_path("../../templates", __FILE__)
6
- @exe_dir = File.expand_path("../../exe", __FILE__)
7
- @local_help_dir = File.join(ENV['HOME'],'.my_help')
8
- @system_inst_dir = RbConfig::CONFIG['bindir']
9
- set_help_dir_if_not_exists
10
- end
11
-
12
- def set_help_dir_if_not_exists
13
- return if File::exists?(@local_help_dir)
14
- FileUtils.mkdir_p(@local_help_dir, :verbose=>true)
15
- Dir.entries(@template_dir).each{|file|
16
- next if file=='template_help.org'
17
- file_path=File.join(@local_help_dir,file)
18
- next if File::exists?(file_path)
19
- FileUtils.cp((File.join(@template_dir,file)),@local_help_dir,:verbose=>true)
20
- }
21
- end
22
-
23
- def show(file, item)
24
- file_path=File.join(@local_help_dir,file+'.org')
25
- help = auto_load(file_path)
26
- print help[:head][:cont]
27
- print '-'*5+"\n"
28
- print item.red+"\n"
29
- print help[item.to_sym][:cont]
30
- end
31
-
32
- def list_helps(file)
33
- if file.nil?
34
- list_all
35
- else
36
- list_help(file)
37
- end
38
- end
39
-
40
- def list_help(file)
41
- file_path=File.join(@local_help_dir,file+'.org')
42
- help = auto_load(file_path)
43
- help.each_pair do |key, conts|
44
- print conts[:cont] if key==:head
45
- disp_opts( conts[:opts] )
46
- end
47
- end
48
-
49
- def disp_opts( conts )
50
- col = 0
51
- conts.each_pair do |key, item|
52
- col_length = case col
53
- when 0; print item.rjust(5)+", "
54
- when 1; print item.ljust(15)+": "
55
- else; print item
56
- end
57
- col += 1
58
- end
59
- print("\n")
60
- end
61
-
62
- def list_all
63
- print "List all helps\n"
64
- local_help_entries.each do |file|
65
- file_path=File.join(@local_help_dir,file)
66
- title = file.split('.')[0]
67
- help = auto_load(file_path)
68
- next if help.nil?
69
- desc = help[:head][:cont].split("\n")[0]
70
- print " #{title}\t: #{desc}\n".blue
71
- end
72
- end
73
-
74
- def edit_help(file)
75
- target_help = File.join(@local_help_dir,file)
76
- ['.yml','.org'].each do |ext|
77
- p target_help += ext if local_help_entries.member?(file+ext)
78
- end
79
- system "emacs #{target_help}"
80
- end
81
-
82
- def init_help(file)
83
- p target_help=File.join(@local_help_dir,file+'.org')
84
- if File::exists?(target_help)
85
- puts "File exists. --delete it first to initialize it."
86
- exit
87
- end
88
- p template = File.join(@template_dir,'template_help.org')
89
- FileUtils::Verbose.cp(template,target_help)
90
- end
91
-
92
- def delete_help(file)
93
- file = File.join(@local_help_dir,file+'.org')
94
- print "Are you sure to delete "+file.blue+"?[Ynq] ".red
95
- case gets.chomp
96
- when 'Y'
97
- begin
98
- FileUtils.rm(file,:verbose=>true)
99
- rescue => error
100
- puts error.to_s.red
101
- end
102
- when 'n', 'q' ; exit
103
- end
104
- end
105
-
106
- private
107
- def local_help_entries
108
- entries= []
109
- Dir.entries(@local_help_dir).each{|file|
110
- next unless file.include?('_')
111
- next if file[0]=='#' or file[-1]=='~' or file[0]=='.'
112
- next if file.match(/(.+)_e\.org/) # OK?
113
- next if file.match(/(.+)\.html/)
114
- entries << file
115
- }
116
- return entries
117
- end
118
-
119
- def auto_load(file_path)
120
- case File.extname(file_path)
121
- when '.yml'
122
- cont = YAML.load(File.read(file_path))
123
- when '.org'
124
- cont = OrgToYaml.new(file_path).help_cont
125
- else
126
- puts "Not handling file types of #{file_path}"
127
- cont = nil
128
- end
129
- cont
130
- end
131
-
132
-
133
- end
134
- end