[gren] gren - 0.2.4、grendbの検索機能を強化

gren - gren is a next grep tool.
gren 0.2.4 をリリースしました。

変更点

検索結果の表示方法を

  1. ファイル単位(インターネットの検索はこちらが多い)
  2. ライン単位(grep等はこちら)

の二通り用意しました。

grendbはファイルデータベースに登録された大量のファイルから検索することが多いため、デフォルトをファイル単位に変更しました。オプションでライン単位の検索も可能です。用途に応じて使い分けていくことになると思います。

今回の修正でデータベースの形式を変えたため、古いバージョンのgrenを使っている人はデータベースの再生成を行う必要があります。

% mkgrendb --full --ddb(or データベース名)

環境変数 GRENDB_DEFAULT_DB を設定しておくと、--ddbオプションでデータベースを指定したことになり便利です。grendbではデータベースを指定せずに検索することが出来ます。

export GRENDB_DEFAULT_DB=~/grendb/grendb.db

mkgrendb

  • データベースの形式を変更
    • 古いmkgrendbで作成したデータベースは、 'mkgrendb --full' で再構築をして下さい。
  • yamlに、ディレクトリではなく単一ファイルの指定もOKに

grendb

  • マッチ対象を行では無くファイルとする --match-file モードを追加
    • 今までのモードは --match-line
    • デフォルトのモードを --match-file に変更
    • 今までの行マッチモードを使う場合は、 -l or --ml or --match-line と指定する
  • 拡張子をキーとする検索モードを追加
    • -s, --suffix
  • --groonga-only オプションを作成
    • 実際のファイルを辿らず、データベースの情報のみで探索出来るように
  • 検索結果を更新時刻順で表示するように

使い方

インストール方法や、grendbの具体的な使い方については、

気がつけば0.2.3、groonga, rroongaと連携して超高速検索をサポート!!

をご覧下さい

--help

0.2.4のオプションです(grenに変更はありません)。

mkgrendb INPUT_YAML1 [INPUT_YAML2 ...]
        --ddb, --default-db          Create or Update default DB. (Plase set ENV['GRENDB_DEFAULT_DB'])
        --full                       Full update DB. (Delete and create)
        --delete                     Delete DB. (Not delete yaml)
        --dump                       Dump DB.
        --report                     Database Report.
grendb [option] keyword1 [keyword2 ...]
        --db [GREN_DB_FILE]          Search from the grendb database.
    -f, --file-keyword KEYWORD       Path keyword. (Enable multiple call)
    -s, --suffix SUFFIX              Search suffix.
    -i, --ignore                     Ignore case.
    -c, --color                      Color highlight.
        --no-snip                    There being a long line, it does not snip.
    -g, --groonga-only               Search only groonga db.
        --mf, --match-file           Match file. (Default)
    -l, --ml, --match-line           Match line, same mode as "gren".
gren [option] pattern
        --not PATTERN                Keyword is not included.
        --or PATTERN                 Either of keyword is contained.
    -d, --directory DIR              Start directory. (deafult:".")
        --depth DEPTH                Limit search depth. 
        --this                       "--depth 0"
    -i, --ignore                     Ignore case.
    -s, --silent                     Silent. Display match line only.
        --debug                      Debug display.
    -c, --color                      Color highlight.
    -f, --file-regexp REGEXP         Search file regexp. (Enable multiple call)
        --if, --ignore-file REGEXP   Ignore file pattern. (Enable multiple call)
        --id, --ignore-dir REGEXP    Ignore dir pattern. (Enable multiple call)
    -e, --encode ENCODE              Specify encode(none, auto, jis, sjis, euc, ascii, utf8, utf16). Default is "auto"
        --no-snip                    There being a long line, it does not snip.