my_help 1.2 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.org +84 -117
- data/README_j.org +143 -0
- data/development_memo.org +242 -0
- data/lib/my_help/cli.rb +6 -1
- data/lib/my_help/version.rb +1 -1
- metadata +4 -9
- data/README_en.org +0 -131
- data/pkg/my_help-0.8.6.gem +0 -0
- data/pkg/my_help-0.9.0.gem +0 -0
- data/pkg/my_help-1.0b.gem +0 -0
- data/pkg/my_help-1.0c.gem +0 -0
- data/pkg/my_help-1.1.gem +0 -0
- data/pkg/my_help-1.1a.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aea4b438a5be4715107a41097ff21fa7d35e8cebed822e9995594bc827c6305
|
4
|
+
data.tar.gz: b964ebdcc06a3e414d5535172a31b69018dbf1cb43db5641101c88f5457a4c91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6d3ce8dcdd71f8e01baecc483f56412791137ab455ba45750966321fb197f7941fd341720bedba55035a3c573d21fea1753d154977a2ddb7c44dfb8751694b0
|
7
|
+
data.tar.gz: 4fcb4b3440365f8364677a6b7aac6d06574cd781e89e277185b0eb54934d976b4df58da318e09c05686fbbe1fd93ca912f458c970d59bfb9445896f4f02568e0
|
data/Gemfile.lock
CHANGED
data/README.org
CHANGED
@@ -1,96 +1,80 @@
|
|
1
|
-
|
2
|
-
#+AUTHOR: Shigeto R. Nishitani
|
3
|
-
#+EMAIL: (concat "nishitani@kwansei.ac.jp")
|
4
|
-
#+LANGUAGE: jp
|
5
|
-
#+OPTIONS: H:4 toc:t num:2
|
6
|
-
#+SETUPFILE: /Users/bob/.emacs.d/org-mode/theme-readtheorg.setup
|
7
|
-
#+STARTUP: indent nolineimages
|
1
|
+
#+STARTUP: indent nolineimages content
|
8
2
|
#+OPTIONS: ^:{}
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
VSCodeやGithub Copilotではcodeの候補を挙げてくれますが,
|
54
|
-
物覚えの悪い作者は,人の名前をitem分けして,こそっと使っています.
|
55
|
-
|
56
|
-
* 使用法
|
57
|
-
:PROPERTIES:
|
58
|
-
:CUSTOM_ID: 使用法
|
59
|
-
:END:
|
60
|
-
** インストール
|
61
|
-
|
62
|
-
: > gem install my_help
|
63
|
-
です.
|
64
|
-
|
65
|
-
** 簡単な使用法
|
66
|
-
:PROPERTIES:
|
67
|
-
:CUSTOM_ID: 簡単な使用法
|
68
|
-
:END:
|
69
|
-
|
70
|
-
まずは,
|
71
|
-
#+begin_src bash
|
3
|
+
* Name
|
4
|
+
- my_help :: manual like help for each user
|
5
|
+
|
6
|
+
* Summary
|
7
|
+
This gem makes and supplies user specific helps, emulating CUI(CLI) help
|
8
|
+
usage.
|
9
|
+
|
10
|
+
* Target
|
11
|
+
A very novice of learning a specific operation,
|
12
|
+
such as CUI, shell, or emacs,
|
13
|
+
has a difficulty in remembering commands and grammers.
|
14
|
+
Some simple `key' reminds all, but no key brings nothing.
|
15
|
+
Especially a non-English-native has a strong difficulty
|
16
|
+
on the key remembering.
|
17
|
+
The problems are,
|
18
|
+
- a man(ual) is in English
|
19
|
+
- a man is heavily documented
|
20
|
+
- On web, searching the same key word,
|
21
|
+
- and reading the same URI repeatedly
|
22
|
+
- but a memo goes away somewhere...
|
23
|
+
|
24
|
+
* Specs
|
25
|
+
This gem aims to supply own help by gem environment.
|
26
|
+
Specs are,
|
27
|
+
- user makes his own help
|
28
|
+
- supplies a template
|
29
|
+
- a same format, looks, operation, and hierarchy
|
30
|
+
- easily see, read
|
31
|
+
- supplies editing and install commands.
|
32
|
+
|
33
|
+
Wiki targets the whole engineer, my_help targets a specific person.
|
34
|
+
Half of the wiki aim should be covered by my_help.
|
35
|
+
Making own manual is one of the best practices for remembering operations.
|
36
|
+
Memo applications are good, if you remember the key word.
|
37
|
+
my_help supplies the key for remembering the word.
|
38
|
+
|
39
|
+
* Usage
|
40
|
+
** Install
|
41
|
+
|
42
|
+
: $ gem install my_help
|
43
|
+
|
44
|
+
** Simple Usage
|
45
|
+
At first, you can see the commands supplied by my_help.
|
46
|
+
#+begin_example
|
72
47
|
> my_help
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
48
|
+
NAME
|
49
|
+
my_help - make own help and list.
|
50
|
+
|
51
|
+
SYNOPSIS
|
52
|
+
my_help [global options] command [command options] [arguments...]
|
53
|
+
|
54
|
+
VERSION
|
55
|
+
0.7.0
|
56
|
+
|
57
|
+
GLOBAL OPTIONS
|
58
|
+
--help - Show this message
|
59
|
+
--version - Display the program version
|
60
|
+
|
61
|
+
COMMANDS
|
62
|
+
delete - delete HELP_NAME help
|
63
|
+
edit - edit HELP_NAME help
|
64
|
+
help - Shows a list of commands or help for one command
|
65
|
+
list - list all helps, specific HELP, or item
|
66
|
+
new - make new HELP_NAME
|
67
|
+
#+end_example
|
68
|
+
|
69
|
+
When you add HELP_NAME and item (-o)wo'
|
70
|
+
|
71
|
+
: my_help list
|
72
|
+
: my_help list emacs_help
|
73
|
+
: my_help list emacs_help -f
|
74
|
+
: my_help list emacs_help file
|
75
|
+
|
76
|
+
|
77
|
+
#+BEGIN_EXAMPLE
|
94
78
|
- emacsのキーバインド
|
95
79
|
-
|
96
80
|
特殊キー操作
|
@@ -111,33 +95,16 @@ Commands:
|
|
111
95
|
, query_replace : query_replace
|
112
96
|
-r, ruby-mode : ruby-mode
|
113
97
|
-d, dired : ファイラとして使う
|
114
|
-
#+
|
115
|
-
|
116
|
-
** my_helpがやっていること
|
117
|
-
my_helpの個々のヘルプファイルは'~/.my_help'に置かれています.
|
118
|
-
ヘルプファイルのフォーマットはEmacsのorg-modeです.
|
119
|
-
これをEditorで叩いて編集したり,
|
120
|
-
そこから情報を取り出したりしています.
|
121
|
-
単にファイル操作を集約しているだけなのですが,
|
122
|
-
これが面倒で...
|
123
|
-
|
124
|
-
|
125
|
-
** 独自のhelpを作る方法
|
126
|
-
独自のhelpを作る方法です.まずは,
|
127
|
-
|
128
|
-
: $ my_help new new_help
|
98
|
+
#+END_EXAMPLE
|
129
99
|
|
130
|
-
|
131
|
-
|
132
|
-
|
100
|
+
** Make your own help
|
101
|
+
For making your new help, you can do tha as follows:
|
102
|
+
: my_help new new_help
|
133
103
|
|
134
|
-
|
104
|
+
A templeate is compied, then you can edit as
|
105
|
+
: my_help edit new_help
|
106
|
+
The file is stored in emacs org mode.
|
135
107
|
|
136
|
-
|
137
|
-
|
138
|
-
: $ my_help set_editor vim
|
139
|
-
でeditorを変更できます.codeとかは確認していますが,
|
140
|
-
それ以外で動いたり,動かなかったりを報告してください.
|
108
|
+
You can delete if as follows:
|
109
|
+
: my_help delete new_help
|
141
110
|
|
142
|
-
OS Xで'emacs'とした時にGUI版が立ち上がって嫌だという場合は,
|
143
|
-
'emacs -nw'として下さい.
|
data/README_j.org
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
# my_help
|
2
|
+
#+AUTHOR: Shigeto R. Nishitani
|
3
|
+
#+EMAIL: (concat "nishitani@kwansei.ac.jp")
|
4
|
+
#+LANGUAGE: jp
|
5
|
+
#+OPTIONS: H:4 toc:t num:2
|
6
|
+
#+SETUPFILE: /Users/bob/.emacs.d/org-mode/theme-readtheorg.setup
|
7
|
+
#+STARTUP: indent nolineimages
|
8
|
+
#+OPTIONS: ^:{}
|
9
|
+
|
10
|
+
* 概要
|
11
|
+
:PROPERTIES:
|
12
|
+
:CUSTOM_ID: 概要
|
13
|
+
:END:
|
14
|
+
|
15
|
+
CUI(CLA)ヘルプのUsage出力を真似て,user独自のhelpを作成・提供するgem.
|
16
|
+
|
17
|
+
|
18
|
+
* (my_helpで解決しようとする)問題点
|
19
|
+
:PROPERTIES:
|
20
|
+
:CUSTOM_ID: my_helpで解決しようとする問題点
|
21
|
+
:END:
|
22
|
+
|
23
|
+
CUIやshell, 何かのプログラミング言語などを習得しようとする初心者は,
|
24
|
+
commandや文法を覚えるのに苦労します.
|
25
|
+
少しのkey(とっかかり)があると思い出すんですが,
|
26
|
+
うろ覚えでは間違えて路頭に迷います.
|
27
|
+
問題点は,
|
28
|
+
+ manは基本的に英語
|
29
|
+
+ manualでは重たい
|
30
|
+
+ いつもおなじことをwebで検索して
|
31
|
+
+ 同じとこ見ている
|
32
|
+
+ memoしても,どこへ置いたか忘れる
|
33
|
+
などです.
|
34
|
+
|
35
|
+
* 特徴
|
36
|
+
:PROPERTIES:
|
37
|
+
:CUSTOM_ID: 特徴
|
38
|
+
:END:
|
39
|
+
|
40
|
+
これらをCLAとして提供しようというのが,このgemの目的です.
|
41
|
+
仕様としては,
|
42
|
+
- userが自分にあったmanを作成
|
43
|
+
- 雛形を提供
|
44
|
+
- おなじformat, looks, 操作, 階層構造
|
45
|
+
- すぐに手が届く
|
46
|
+
- それらを追加・修正・削除できる
|
47
|
+
|
48
|
+
memoソフトでは,検索が必要となりますが,my_helpは
|
49
|
+
key(記憶のとっかかり)を提供することが目的です.
|
50
|
+
RPGでレベル上げとかアイテムを貯めるようにして,
|
51
|
+
プログラミングでスキルを発展させてください.
|
52
|
+
|
53
|
+
VSCodeやGithub Copilotではcodeの候補を挙げてくれますが,
|
54
|
+
物覚えの悪い作者は,人の名前をitem分けして,こそっと使っています.
|
55
|
+
|
56
|
+
* 使用法
|
57
|
+
:PROPERTIES:
|
58
|
+
:CUSTOM_ID: 使用法
|
59
|
+
:END:
|
60
|
+
** インストール
|
61
|
+
|
62
|
+
: > gem install my_help
|
63
|
+
です.
|
64
|
+
|
65
|
+
** 簡単な使用法
|
66
|
+
:PROPERTIES:
|
67
|
+
:CUSTOM_ID: 簡単な使用法
|
68
|
+
:END:
|
69
|
+
|
70
|
+
まずは,
|
71
|
+
#+begin_src bash
|
72
|
+
> my_help
|
73
|
+
Commands:
|
74
|
+
my_help delete HELP # delete HELP
|
75
|
+
my_help edit HELP # edit HELP
|
76
|
+
my_help help [COMMAND] # Describe available commands or one specific command
|
77
|
+
my_help list [HELP] [ITEM] # list all helps, specific HELP, or ITEM
|
78
|
+
my_help new HELP # make new HELP
|
79
|
+
my_help set_editor EDITOR_NAME # set editor to EDITOR_NAME
|
80
|
+
my_help setup # set up the test database
|
81
|
+
my_help version # show version
|
82
|
+
#+end_src
|
83
|
+
としてください.このlistにNAMEやITEMを加えて行くとわかると思います.
|
84
|
+
|
85
|
+
#+begin_src bash
|
86
|
+
> my_help list
|
87
|
+
> my_help list emacs
|
88
|
+
> my_help list emacs -f
|
89
|
+
> my_help list emacs file
|
90
|
+
#+end_src
|
91
|
+
として動かしてみてください.
|
92
|
+
|
93
|
+
#+begin_src bash
|
94
|
+
- emacsのキーバインド
|
95
|
+
-
|
96
|
+
特殊キー操作
|
97
|
+
- C-f, controlキーを押しながら 'f'
|
98
|
+
- M-f, escキーを押した後一度離して'f'
|
99
|
+
- 操作の中断C-g, 操作の取り消し(Undo) C-x u
|
100
|
+
, head : head
|
101
|
+
, license : license
|
102
|
+
-c, cursor : cursor
|
103
|
+
-e, edit : edit
|
104
|
+
-s, short_cut : short_cut
|
105
|
+
-f, file : file
|
106
|
+
-q, quit : quit
|
107
|
+
-p, page : page
|
108
|
+
-w, window : window
|
109
|
+
-b, buffer : buffer
|
110
|
+
-m, mode : mode
|
111
|
+
, query_replace : query_replace
|
112
|
+
-r, ruby-mode : ruby-mode
|
113
|
+
-d, dired : ファイラとして使う
|
114
|
+
#+end_src
|
115
|
+
|
116
|
+
** my_helpがやっていること
|
117
|
+
my_helpの個々のヘルプファイルは'~/.my_help'に置かれています.
|
118
|
+
ヘルプファイルのフォーマットはEmacsのorg-modeです.
|
119
|
+
これをEditorで叩いて編集したり,
|
120
|
+
そこから情報を取り出したりしています.
|
121
|
+
単にファイル操作を集約しているだけなのですが,
|
122
|
+
これが面倒で...
|
123
|
+
|
124
|
+
|
125
|
+
** 独自のhelpを作る方法
|
126
|
+
独自のhelpを作る方法です.まずは,
|
127
|
+
|
128
|
+
: $ my_help new new_help
|
129
|
+
|
130
|
+
で,new_helpというtemplateが用意されます.
|
131
|
+
: $ my_help edit new_help
|
132
|
+
で編集してください. Emacs org形式で,格納されています.
|
133
|
+
|
134
|
+
: $ my_help delete new_help
|
135
|
+
|
136
|
+
すると消されます.
|
137
|
+
** editorの変更
|
138
|
+
: $ my_help set_editor vim
|
139
|
+
でeditorを変更できます.codeとかは確認していますが,
|
140
|
+
それ以外で動いたり,動かなかったりを報告してください.
|
141
|
+
|
142
|
+
OS Xで'emacs'とした時にGUI版が立ち上がって嫌だという場合は,
|
143
|
+
'emacs -nw'として下さい.
|
@@ -0,0 +1,242 @@
|
|
1
|
+
#+qiita_teams: 5e172c4b5167abe35a3e
|
2
|
+
#+qiita_private: 6487b0b54e4eda26e9f6
|
3
|
+
#+OPTIONS: ^:{}
|
4
|
+
#+STARTUP: indent nolineimages
|
5
|
+
#+TITLE: my_help 開発メモ
|
6
|
+
#+AUTHOR: Shigeto R. Nishitani
|
7
|
+
#+EMAIL: (concat "shigeto_nishitani@mac.com")
|
8
|
+
#+LANGUAGE: jp
|
9
|
+
#+OPTIONS: H:4 toc:t num:2
|
10
|
+
# +OPTIONS: toc:nil
|
11
|
+
#+TAG: ruby, test, my_help
|
12
|
+
#+TWITTER: off
|
13
|
+
#+SETUPFILE: https://fniessen.github.io/org-html-themes/org/theme-readtheorg.setup
|
14
|
+
|
15
|
+
* <2023-01-07 Sat> Thor
|
16
|
+
いくつかのaliasをThorで実現したい
|
17
|
+
- my_help -v
|
18
|
+
- my_help --version
|
19
|
+
という標準的なoption期待に答える.
|
20
|
+
|
21
|
+
- [[https://marsbased.com/blog/2020/04/27/building-ruby-cli-thor/][author token, aliases sample]]
|
22
|
+
- [[https://stackoverflow.com/questions/28504373/command-aliasing-in-thor][map]]
|
23
|
+
なんかの記述があったが,
|
24
|
+
- https://github.com/rails/thor/wiki
|
25
|
+
で解決.やっぱり原典ね.
|
26
|
+
|
27
|
+
あと,その後ろの方に,例文の引き方があって,
|
28
|
+
- https://gist.github.com/search?l=ruby&q=.thor
|
29
|
+
が便利なんがわかった.これは,使える.
|
30
|
+
|
31
|
+
|
32
|
+
* <2023-01-06 Fri> get_configの置き場所
|
33
|
+
Thorのsubcommandを使ってclassを分けたが,共通で利用する
|
34
|
+
get_configメソッドをどこに置くかで悩んだ.
|
35
|
+
|
36
|
+
結局,
|
37
|
+
#+begin_src ruby
|
38
|
+
# git_cli.rb
|
39
|
+
Module MyHelp
|
40
|
+
Module GetConfig
|
41
|
+
Class Git < Thor
|
42
|
+
include GetConfig
|
43
|
+
...
|
44
|
+
end
|
45
|
+
# cli.rb
|
46
|
+
Module MyHelp
|
47
|
+
Class CLI < Thor
|
48
|
+
include GetConfig
|
49
|
+
...
|
50
|
+
end
|
51
|
+
# my_help.rb
|
52
|
+
require_relative "my_help/git_cli"
|
53
|
+
require_relative "my_help/cli"
|
54
|
+
#+end_src
|
55
|
+
としている.
|
56
|
+
専用のModuleを作成して,includeするという方法.
|
57
|
+
* <2023-01-05 Thu> cli directory指定
|
58
|
+
** directory指定
|
59
|
+
テスト環境と本番環境でのhelp_dirあるいはconfig_dir指定の
|
60
|
+
差異の吸収メモ.
|
61
|
+
- --help_dirでcliはhelp_dirを指定できる.
|
62
|
+
- 全て変更したはず.
|
63
|
+
- configが混乱しやすい...config[:ext]なんかを自動で返すといいが.
|
64
|
+
- rspec/unitでは
|
65
|
+
- config_spec.rb, modify_spec.rbではtmp_confをtemp_dirに作成
|
66
|
+
- list_spec.rbではtemplates_pathを絶対パスで参照
|
67
|
+
|
68
|
+
** Thorでのdirectory指定の変更
|
69
|
+
Thorのdirectory指定をしっかりやってみる.
|
70
|
+
|
71
|
+
#+begin_src bash
|
72
|
+
bundle exec rspec --format documentation -e list spec/cli_spec.rb --help_dir='./tmp/.my_Help'
|
73
|
+
invalid option: --help_dir=./tmp/.my_Help
|
74
|
+
|
75
|
+
Please use --help for a listing of valid options
|
76
|
+
#+end_src
|
77
|
+
これはだめ.なぜなら,--help_dirはmy_helpのlistのoptionであって,
|
78
|
+
rspecは解釈してくれない.
|
79
|
+
|
80
|
+
ここは,cli_spec.rbで
|
81
|
+
#+begin_src ruby
|
82
|
+
temp_dir = Dir.pwd
|
83
|
+
let(:help_name) { "example" }
|
84
|
+
let(:help_dir) { File.join(temp_dir, "lib", "templates") }
|
85
|
+
|
86
|
+
it "list with name" do
|
87
|
+
run_command("my_help list #{help_name} a_item --help_dir=#{help_dir}")
|
88
|
+
stop_all_commands
|
89
|
+
expect(last_command_started).to have_output(/a_item/)
|
90
|
+
end
|
91
|
+
#+end_src
|
92
|
+
とすべき.
|
93
|
+
|
94
|
+
そうすると
|
95
|
+
#+begin_src bash
|
96
|
+
bundle exec exe/my_help list --help_dir='/Users/bob/git_hub/my_help/lib/templates'
|
97
|
+
#+end_src
|
98
|
+
でも動く.
|
99
|
+
そうしておいて,optionsを移動.
|
100
|
+
|
101
|
+
今は,
|
102
|
+
#+begin_src bash
|
103
|
+
> bundle exec exe/my_help help list
|
104
|
+
Usage:
|
105
|
+
my_help list [HELP] [ITEM]
|
106
|
+
|
107
|
+
Options:
|
108
|
+
[--help-dir=HELP_DIR]
|
109
|
+
[--layer=N]
|
110
|
+
|
111
|
+
list helps
|
112
|
+
#+end_src
|
113
|
+
となっていたが,
|
114
|
+
|
115
|
+
#+begin_src bash
|
116
|
+
bundle exec exe/my_help
|
117
|
+
Commands:
|
118
|
+
my_help delete [HELP] # delete HELP
|
119
|
+
my_help edit [HELP] # edit help
|
120
|
+
...
|
121
|
+
Options:
|
122
|
+
[--help-dir=HELP_DIR]
|
123
|
+
#+end_src
|
124
|
+
とclass_optionとすることで,共通して指定できるように変更.
|
125
|
+
|
126
|
+
* <2022-12-15 Thu> subcommand and options
|
127
|
+
- [[https://hawksnowlog.blogspot.com/2020/09/ruby-thor-tutorial.html#hello-thor][Ruby thor で CLI ツールの開発に入門してみる]]
|
128
|
+
|
129
|
+
* <2022-12-15 Thu> rspecでerror
|
130
|
+
Arubaでrspecするとpwd directoryが/tmp/arubaになる?
|
131
|
+
そうすると今のままではrspecが通らなくなる.
|
132
|
+
example2.orgの置き場が不定.
|
133
|
+
spec側で強引に作るか...
|
134
|
+
|
135
|
+
それもsmartにしたいよね.
|
136
|
+
newでは後ろにoptionがあって,#{temp_dir}での作成とできるが,
|
137
|
+
これをその他のoptionsでやるのは難しそう.
|
138
|
+
|
139
|
+
** 解決!!
|
140
|
+
Arubaだけの問題なので,テストの時用にhelp_dirを
|
141
|
+
Thorのoptionとして引けるようにした.
|
142
|
+
#+begin_src ruby -n
|
143
|
+
desc "list [HELP] [ITEM]", "list helps"
|
144
|
+
option :help_dir, :type => :string
|
145
|
+
# use method_options [[https://github.com/rails/thor/wiki/Method-Options]]
|
146
|
+
def list(*args)
|
147
|
+
config = get_config(args).config
|
148
|
+
help_dir = options["help_dir"] || config[:local_help_dir]
|
149
|
+
puts List.new(help_dir,
|
150
|
+
config[:ext]).list(*args.join(" "))
|
151
|
+
end
|
152
|
+
...
|
153
|
+
context "list command" do
|
154
|
+
temp_dir = Dir.pwd
|
155
|
+
let(:help_name) { "example" }
|
156
|
+
let(:help_dir) { File.join(temp_dir, "lib", "templates") }
|
157
|
+
|
158
|
+
it "list with name" do
|
159
|
+
run_command("my_help list #{help_name} a_item --help_dir=#{help_dir}")
|
160
|
+
stop_all_commands
|
161
|
+
expect(last_command_started).to have_output(/a_item/)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
#+end_src
|
166
|
+
|
167
|
+
* <2021-10-18 月> conf_pathの追加
|
168
|
+
my_help.confの場所を指定するconf_pathをnewで指定できるようにする.
|
169
|
+
|
170
|
+
#+begin_src diff -n -i
|
171
|
+
> git diff
|
172
|
+
--- a/lib/my_help/my_help_controll.rb
|
173
|
+
+++ b/lib/my_help/my_help_controll.rb
|
174
|
+
@@ -5,13 +5,14 @@ require 'yaml'
|
175
|
+
module MyHelp
|
176
|
+
class Control
|
177
|
+
attr_accessor :local_help_dir, :editor
|
178
|
+
- def initialize()
|
179
|
+
+ def initialize(conf_path=nil)
|
180
|
+
# for configuration setups
|
181
|
+
# see https://stackoverflow.com/questions/6233124/where-to-place-access-config-file-in-gem
|
182
|
+
-
|
183
|
+
+ @conf_path = conf_path || ENV['HOME']
|
184
|
+
@template_dir = File.expand_path("../../templates", __FILE__)
|
185
|
+
@exe_dir = File.expand_path("../../exe", __FILE__)
|
186
|
+
- @local_help_dir = File.join(ENV['HOME'],'.my_help')
|
187
|
+
+ @local_help_dir = File.join(@conf_path, '.my_help')
|
188
|
+
+ @conf_file = File.join(@local_help_dir, '.my_help_conf.yml')
|
189
|
+
@editor = ENV['EDITOR'] || 'emacs' #'code', 'emacs' #'vim' #default editor
|
190
|
+
# @mini_account = File
|
191
|
+
set_help_dir_if_not_exists
|
192
|
+
@@ -28,9 +29,6 @@ module MyHelp
|
193
|
+
end
|
194
|
+
|
195
|
+
def load_conf
|
196
|
+
- file_name = '.my_help_conf.yml'
|
197
|
+
- # @conf_file = File.join(Dir.pwd, file_name)
|
198
|
+
- @conf_file = File.join(@local_help_dir, file_name)
|
199
|
+
begin
|
200
|
+
conf = YAML.load_file(@conf_file)
|
201
|
+
@editor = conf[:editor]
|
202
|
+
#+end_src
|
203
|
+
|
204
|
+
変更箇所は次の通り.
|
205
|
+
- initializeはconf_pathを受け取るが,指定されてない時はnil
|
206
|
+
- これを@conf_pathに受け渡すが,defaultをENV['HOME']に指定
|
207
|
+
- これでデフォルトのconfigurationを変更していく
|
208
|
+
やり方は,
|
209
|
+
[[https://stackoverflow.com/questions/6233124/where-to-place-access-config-file-in-gem][Where to place/access config file in gem?]]
|
210
|
+
を参照する.
|
211
|
+
|
212
|
+
これによってTest::unitでのtest環境独自のmy_help環境を構築することが
|
213
|
+
できる.
|
214
|
+
|
215
|
+
* <2021-11-08 月> conf_pathをactivate
|
216
|
+
testが進んできたので,conf_pathをactivateした.
|
217
|
+
そのためのテストが必要かも.
|
218
|
+
|
219
|
+
1. ENV['HOME']で指定した時と...
|
220
|
+
1. pwdで何もない時のoptionsがどうなっている?
|
221
|
+
|
222
|
+
#+begin_src yaml
|
223
|
+
config:
|
224
|
+
:template_dir: "/Users/bob/git_hub/my_help/lib/templates"
|
225
|
+
:local_help_dir: "/Users/bob/git_hub/my_help/test/.my_help"
|
226
|
+
:conf_file: "/Users/bob/git_hub/my_help/test/.my_help/.my_help_conf.yml"
|
227
|
+
:editor: emacs
|
228
|
+
#+end_src
|
229
|
+
|
230
|
+
* <2021-11-08 月> bundle exec exe/my_help editでエラー
|
231
|
+
#+begin_src shell
|
232
|
+
Could not find ffi-1.15.4 in any of the sources
|
233
|
+
Run `bundle install` to install missing gems.
|
234
|
+
#+end_src
|
235
|
+
とのエラー.
|
236
|
+
なんだろう.
|
237
|
+
|
238
|
+
さらに,command_lineで呼ぶと,
|
239
|
+
: emacs: standard input is not a tty
|
240
|
+
というエラーが出る.これまたなんだろう???
|
241
|
+
|
242
|
+
|
data/lib/my_help/cli.rb
CHANGED
@@ -13,10 +13,14 @@ module MyHelp
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
package_name 'my_help'
|
17
|
+
map "-v" => :version
|
18
|
+
map "--version" => :version
|
19
|
+
|
16
20
|
desc "version", "show version"
|
17
21
|
|
18
22
|
def version
|
19
|
-
|
23
|
+
print "my_help #{VERSION}"
|
20
24
|
end
|
21
25
|
|
22
26
|
desc "git [pull|push]", "git operations"
|
@@ -102,5 +106,6 @@ module MyHelp
|
|
102
106
|
name = $stdin.gets.chomp
|
103
107
|
puts("Hello #{name}.")
|
104
108
|
end
|
109
|
+
|
105
110
|
end
|
106
111
|
end
|
data/lib/my_help/version.rb
CHANGED
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:
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shigeto R. Nishiani
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -104,8 +104,9 @@ files:
|
|
104
104
|
- Gemfile.lock
|
105
105
|
- LICENSE.txt
|
106
106
|
- README.org
|
107
|
-
-
|
107
|
+
- README_j.org
|
108
108
|
- Rakefile
|
109
|
+
- development_memo.org
|
109
110
|
- doc/MyHelp.html
|
110
111
|
- doc/MyHelp/CLI.html
|
111
112
|
- doc/MyHelp/Config.html
|
@@ -150,12 +151,6 @@ files:
|
|
150
151
|
- lib/templates/example.md
|
151
152
|
- lib/templates/example.org
|
152
153
|
- my_help.gemspec
|
153
|
-
- pkg/my_help-0.8.6.gem
|
154
|
-
- pkg/my_help-0.9.0.gem
|
155
|
-
- pkg/my_help-1.0b.gem
|
156
|
-
- pkg/my_help-1.0c.gem
|
157
|
-
- pkg/my_help-1.1.gem
|
158
|
-
- pkg/my_help-1.1a.gem
|
159
154
|
- tmp.txt
|
160
155
|
homepage: https://github.com/daddygongon/my_help
|
161
156
|
licenses:
|
data/README_en.org
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
* Name
|
2
|
-
:PROPERTIES:
|
3
|
-
:CUSTOM_ID: name
|
4
|
-
:END:
|
5
|
-
|
6
|
-
my\_help
|
7
|
-
|
8
|
-
* Summary
|
9
|
-
:PROPERTIES:
|
10
|
-
:CUSTOM_ID: summary
|
11
|
-
:END:
|
12
|
-
|
13
|
-
This gem makes and supplies user specific helps, emulating CUI(CLI) help
|
14
|
-
usage.
|
15
|
-
|
16
|
-
* Target
|
17
|
-
:PROPERTIES:
|
18
|
-
:CUSTOM_ID: target
|
19
|
-
:END:
|
20
|
-
|
21
|
-
A very novice of learning some specific operation, such as CUI, shell,
|
22
|
-
or emacs, has difficulty in remembering commands and grammers. If he has
|
23
|
-
a key, he can easily remember all, but no key brings nothing. Especially
|
24
|
-
a non-English-native has strong difficulty on the key rememebering. The
|
25
|
-
problems are,
|
26
|
-
|
27
|
-
- man(ual) is English
|
28
|
-
- man is heavily documented
|
29
|
-
- On web, search the same key word,
|
30
|
-
- and read the same URI repeatedly
|
31
|
-
- memo goes away somewhere...
|
32
|
-
|
33
|
-
* Specs
|
34
|
-
:PROPERTIES:
|
35
|
-
:CUSTOM_ID: specs
|
36
|
-
:END:
|
37
|
-
|
38
|
-
This gem aims to supply own help by gem environment. Specs are, - user
|
39
|
-
makes his own help - supplies a template - same format, looks,
|
40
|
-
operation, and hierarchy - easily see, read - supplies editing and
|
41
|
-
install commands.
|
42
|
-
|
43
|
-
Wiki targets the whole engineer, my\_help target the specific person.
|
44
|
-
Half of the wiki aim should be covered by my\_help. Making own manual is
|
45
|
-
one of the best practices for remembering operations. Memo applications
|
46
|
-
are good, if you remember the key word. my\_help supplies the key for
|
47
|
-
remembering the word.
|
48
|
-
|
49
|
-
* Usage
|
50
|
-
:PROPERTIES:
|
51
|
-
:CUSTOM_ID: 使用法
|
52
|
-
:END:
|
53
|
-
** Install
|
54
|
-
|
55
|
-
: $ gem install my_help
|
56
|
-
|
57
|
-
** Simple Usage
|
58
|
-
:PROPERTIES:
|
59
|
-
:CUSTOM_ID: 簡単な使用法
|
60
|
-
:END:
|
61
|
-
|
62
|
-
At first, you can see the commands supplied by my_help.
|
63
|
-
#+begin_example
|
64
|
-
> my_help
|
65
|
-
NAME
|
66
|
-
my_help - make own help and list.
|
67
|
-
|
68
|
-
SYNOPSIS
|
69
|
-
my_help [global options] command [command options] [arguments...]
|
70
|
-
|
71
|
-
VERSION
|
72
|
-
0.7.0
|
73
|
-
|
74
|
-
GLOBAL OPTIONS
|
75
|
-
--help - Show this message
|
76
|
-
--version - Display the program version
|
77
|
-
|
78
|
-
COMMANDS
|
79
|
-
delete - delete HELP_NAME help
|
80
|
-
edit - edit HELP_NAME help
|
81
|
-
help - Shows a list of commands or help for one command
|
82
|
-
list - list all helps, specific HELP, or item
|
83
|
-
new - make new HELP_NAME
|
84
|
-
#+end_example
|
85
|
-
|
86
|
-
When you add HELP_NAME and item (-o)wo'
|
87
|
-
|
88
|
-
: my_help list
|
89
|
-
: my_help list emacs_help
|
90
|
-
: my_help list emacs_help -f
|
91
|
-
: my_help list emacs_help file
|
92
|
-
|
93
|
-
|
94
|
-
#+BEGIN_EXAMPLE
|
95
|
-
- emacsのキーバインド
|
96
|
-
-
|
97
|
-
特殊キー操作
|
98
|
-
- C-f, controlキーを押しながら 'f'
|
99
|
-
- M-f, escキーを押した後一度離して'f'
|
100
|
-
- 操作の中断C-g, 操作の取り消し(Undo) C-x u
|
101
|
-
, head : head
|
102
|
-
, license : license
|
103
|
-
-c, cursor : cursor
|
104
|
-
-e, edit : edit
|
105
|
-
-s, short_cut : short_cut
|
106
|
-
-f, file : file
|
107
|
-
-q, quit : quit
|
108
|
-
-p, page : page
|
109
|
-
-w, window : window
|
110
|
-
-b, buffer : buffer
|
111
|
-
-m, mode : mode
|
112
|
-
, query_replace : query_replace
|
113
|
-
-r, ruby-mode : ruby-mode
|
114
|
-
-d, dired : ファイラとして使う
|
115
|
-
#+END_EXAMPLE
|
116
|
-
|
117
|
-
** Make your own help
|
118
|
-
:PROPERTIES:
|
119
|
-
:CUSTOM_ID: 独自のhelpを作る方法
|
120
|
-
:END:
|
121
|
-
|
122
|
-
For making your new help, you can do tha as follows:
|
123
|
-
: my_help new new_help
|
124
|
-
|
125
|
-
A templeate is compied, then you can edit as
|
126
|
-
: my_help edit new_help
|
127
|
-
The file is stored in emacs org mode.
|
128
|
-
|
129
|
-
You can delete if as follows:
|
130
|
-
: my_help delete new_help
|
131
|
-
|
data/pkg/my_help-0.8.6.gem
DELETED
Binary file
|
data/pkg/my_help-0.9.0.gem
DELETED
Binary file
|
data/pkg/my_help-1.0b.gem
DELETED
Binary file
|
data/pkg/my_help-1.0c.gem
DELETED
Binary file
|
data/pkg/my_help-1.1.gem
DELETED
Binary file
|
data/pkg/my_help-1.1a.gem
DELETED
Binary file
|