c-3lab / dim

📦 dim: Manage the open data in your project like a package manager.
MIT License
124 stars 21 forks source link

add type option to search command #104

Open MitsukiUsui opened 1 year ago

MitsukiUsui commented 1 year ago

https://github.com/c-3lab/dim/issues/99

MitsukiUsui commented 1 year ago

成功例

$ deno run -A dim.ts search "東京 避難所" -n 1
132047_東京都_三鷹市_避難所
  - Catalog URL        : https://www.geospatial.jp/ckan/dataset/132047-002
  - Catalog Description: ####避難所のデータです。 / ####東京都三鷹市のオープンデータです。【リソース】避難所(2018年6月5日更新)(CSV5KB) / ####避難所データのCSVです。 / ####更新日:2018年7月20日【キーワード】三鷹市 / 東京都 / 避難所
  - Catalog License    : CC-BY4.0
    1. 避難所(2018年6月5日更新)(CSV5KB)
      * Resource URL        : https://www.geospatial.jp/ckan/dataset/08ef40b5-082e-4eb5-9be4-317e88a0f0a8/resource/824bd25f-ba55-4908-b857-793fdea70cf5/download/hinanjyo.csv
      * Resource Description: ####避難所データのCSVです。
####更新日:2018年7月20日
      * Created             : 2018-10-30T02:31:05.931229
      * Format              : CSV
$ deno run -A dim.ts search "東京 避難所" -n 1 --type json
[
  {
    xckan_id: "www.geospatial.jp__ckan__dataset:132047-002",
    xckan_title: "132047_東京都_三鷹市_避難所",
    xckan_site_name: "G空間情報センター",
    xckan_site_url: "https://www.geospatial.jp/ckan/dataset/132047-002",
    xckan_last_updated: "2020-02-04T10:16:20Z",
$ deno run -A dim.ts search "東京 避難所" -n 1 --type text
132047_東京都_三鷹市_避難所
  - Catalog URL        : https://www.geospatial.jp/ckan/dataset/132047-002
  - Catalog Description: ####避難所のデータです。 / ####東京都三鷹市のオープンデータです。【リソース】避難所(2018年6月5日更新)(CSV5KB) / ####避難所データのCSVです。 / ####更新日:2018年7月20日【キーワード】三鷹市 / 東京都 / 避難所
  - Catalog License    : CC-BY4.0
    1. 避難所(2018年6月5日更新)(CSV5KB)
      * Resource URL        : https://www.geospatial.jp/ckan/dataset/08ef40b5-082e-4eb5-9be4-317e88a0f0a8/resource/824bd25f-ba55-4908-b857-793fdea70cf5/download/hinanjyo.csv
      * Resource Description: ####避難所データのCSVです。
####更新日:2018年7月20日
      * Created             : 2018-10-30T02:31:05.931229
      * Format              : CSV

失敗例

[mitsuki@local ~/sandbox/dim]$ deno run -A dim.ts search "東京 避難所" -n 1 --type invalid
Invalid search result type. Please select from [text|json]
$ deno run -A dim.ts search "東京 避難所" -n 1 --type json -i
You can not use 'json' type for interactive installation.
MitsukiUsui commented 1 year ago
$ deno run -A dim.ts search -h

  Usage:   dim search <keyword>
  Version: v1.0.3  (New version available: v1.0.4. Run 'dim upgrade' to upgrade to the latest version!)

  Description:

    Search data from package_search CKAN API

  Options:

    -h, --help               - Show this help.
    -n, --number   <number>  - Specify the number of data to get by option -n (default 10).  (Default: 10)
    -i, --install            - Interactive installation.
    -t, --type     <type>    - Specify search result format [text|json].                     (Default: "text")
codecov[bot] commented 1 year ago

Codecov Report

Merging #104 (bca49cf) into main (69f1d32) will decrease coverage by 1.16%. The diff coverage is 74.60%.

@@             Coverage Diff             @@
##              main     #104      +/-   ##
===========================================
- Coverage   100.00%   98.84%   -1.16%     
===========================================
  Files           20       21       +1     
  Lines         1353     1383      +30     
  Branches       144      147       +3     
===========================================
+ Hits          1353     1367      +14     
- Misses           0       15      +15     
- Partials         0        1       +1     
Impacted Files Coverage Δ
libs/actions.ts 96.17% <27.77%> (-3.83%) :arrow_down:
libs/action_helper/searcher.ts 92.30% <92.30%> (ø)
dim.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.