LoginSignup
0
0

More than 3 years have passed since last update.

milkode の導入

Posted at

はじめに

複数パッケージのソースコードを対象にgrepするのはめんどくさい。
手早くテキストやソースコードにgrepかけてくれるものとしてmilkodeを入れてみる。

env

$ uname -r
4.19.104-microsoft-standard
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04 LTS"

install

$ sudo apt install ruby ruby-dev
$ sudo gem install milkode

initialize

$ milk init --default
Deprecation warning: Expected string default value for '--port'; got 9292 (numeric).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
create     : /home/tkhshmsy/.milkode/milkode.yaml
create     : /home/tkhshmsy/.milkode/db/milkode.db created.

add/remove

すでに4つほどpackageを追加済み。

$ git clone https://github.com/tkhshmsy/hogehoge.git
Cloning into 'hogehoge'...
remote: Enumerating objects: 87, done.
remote: Total 87 (delta 0), reused 0 (delta 0), pack-reused 87
Unpacking objects: 100% (87/87), 599.91 KiB | 777.00 KiB/s, done.

$ milk add hogehoge/
Deprecation warning: Expected string default value for '--port'; got 9292 (numeric).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
package    : hogehoge
github     : tkhshmsy/hogehoge
result     : 1 packages, 73 records, 73 add. (0.98sec)
*milkode*  : 5 packages, 976 records in /home/tkhshmsy/.milkode/db/milkode.db.

$ milk rm hogehoge/
Deprecation warning: Expected string default value for '--port'; got 9292 (numeric).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
rm_package : hogehoge
result     : 1 packages, 73 records. (0.97sec)
*milkode*  : 4 packages, 903 records in /home/tkhshmsy/.milkode/db/milkode.db.

update

$ milk update --all
Deprecation warning: Expected string default value for '--port'; got 9292 (numeric).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
package    : package1
package    : package2
package    : package3
package    : package4
result     : 4 packages, 903 records. (0.18sec)
*milkode*  : 4 packages, 903 records in /home/tkhshmsy/.milkode/db/milkode.db.

settings

  • コマンドラインからの検索にはgmilkを使う
  • 色付き、全パッケージ検索に設定
.bashrc
alias gmilk='gmilk -a --color'

Web UI

WebUIを起動する。デフォルトの公開ポートは9292。

$ milk web -o `hostname -I` -n

WebUIをWindows側から起動できるようにする

Windowsでショートカットを作る
- デスクトップの何もないところで右クリック=>ショートカットの作成
- wsl.exeを実行するように設定
- 項目にwslとだけ書いて次へ(参照をする必要なし)
- ショートカット名を編集、完了
- できたショートカットを右クリック、プロパティ
- リンク先にコマンドラインを書く

wsl.exe - u <User> -- milk web -o `hostname -I` -n

できたショートカットをダブルクリックして実行するとでmilk webが実行される。

IPアドレスとポート番号は標準出力に出ているのでそれをブラウザで開く。

止めるときは、

  • このウインドウをAlt+F4してもプロセスは止まらない
  • プロセスを止めたいときはCTRL+Cで終了する、とウインドウも閉じる
    • 別口からkillでもいい

どうなった?

単一のパッケージ内ならあまり必要性はないが、

  • 複数パッケージにまたがる処理を追いかける時
  • 他のパッケージのコードを参考に書く時

などには重宝する。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0