dotnet cli 5.0 新特性——dotnet tool search

WeihanLi發表於2021-01-26

dotnet cli 5.0 新特性——dotnet tool search

Intro

.NET 5.0 SDK 的釋出,給 dotnet cli 引入了一個新的特性,dotnet tool search,主要用於搜尋 Nuget 上的 dotnet tool,這個命令會搜尋 tool 的名稱以及一些後設資料, titles, descriptions, 和 tags

Synopsis

dotnet tool search [--detail] [--prerelease]
[--skip ] [--take ]

dotnet tool search -h|--help

可以通過 dotnet tool search -h 檢視支援的引數,支援的引數如下:

  • --detail

    顯示詳細結果

  • --prerelease

    是否包含預覽版

  • --skip <NUMBER>

    跳過前面多少條資料,用於分頁

  • --take <NUMBER>

    指定要返回的資料條數,用於分頁查詢

Examples

來看幾個簡單的示例:

使用 dotnet tool search <keyword> 進行最基本的搜尋,

使用 dotnet tool search <keyword> --skip <skip> --take <take> 來進行分頁查詢

使用 dotnet tool search <keyword> --take 1 --detail 查詢詳細資訊

More

這個功能從 .NET 5.0 SDK 之後才支援,它的實現方式倒是很簡單,直接呼叫了 Nuget 的介面,通過 packageType=dotnettool 只查詢 dotnet tool

用抓包工具抓個包看看,search 的時候做了什麼,search 的時候會呼叫 nuget 的介面,介面呼叫情況如下:

有了這個我們即使不完全記得 package tool 的型別,我們也可以通過命令進行查詢,方便了很多

References

相關文章