diff options
| author | ruki <[email protected]> | 2017-09-29 00:49:28 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-09-28 22:56:52 +0800 |
| commit | 371b4a11894b2f784f03f805d35683469614f213 (patch) | |
| tree | 163c17aa4d5c595473c3d6d72d5fccd10f878ba3 | |
| parent | 0e989f2c215ba7a13550442655dc57a22434519f (diff) | |
add require --info
| -rw-r--r-- | xmake/actions/require/info.lua | 66 | ||||
| -rw-r--r-- | xmake/actions/require/list.lua | 1 | ||||
| -rw-r--r-- | xmake/actions/require/main.lua | 4 |
3 files changed, 67 insertions, 4 deletions
diff --git a/xmake/actions/require/info.lua b/xmake/actions/require/info.lua index 8653cbca3..bbeff3ea0 100644 --- a/xmake/actions/require/info.lua +++ b/xmake/actions/require/info.lua @@ -22,8 +22,70 @@ -- @file info.lua -- +-- imports +import("core.base.task") +import("action.filter") +import("package") +import("repository") +import("environment") + -- show the given package info -function main(packages) - -- TODO +function main(requires) + + -- no requires? + if not requires then + return + end + + -- enter environment + environment.enter() + + -- pull all repositories first if not exists + if not repository.pulled() then + task.run("repo", {update = true}) + end + + -- show title + print("The package info:") + + -- list all packages + for _, instance in ipairs(package.load_packages(requires)) do + + -- show package name + local requireinfo = instance:requireinfo() or {} + cprint(" ${magenta}require${clear}(%s):", requireinfo.originstr) + + -- show description + local description = instance:get("description") + if description then + cprint(" -> ${magenta}description${clear}: %s", description) + end + + -- show version + local version = instance:version_str() + if version then + cprint(" -> ${magenta}version${clear}: %s", version) + end + + -- show urls + cprint(" -> ${magenta}urls${clear}:") + for _, url in ipairs(instance:urls()) do + print(" -> %s", filter.handle(url, instance)) + local sha256 = instance:sha256(instance:url_alias(url)) + if sha256 then + cprint(" -> ${yellow}%s${clear}", sha256) + end + end + + -- show deps + cprint(" -> ${magenta}deps${clear}:") + for _, dep in ipairs(instance:orderdeps()) do + requireinfo = dep:requireinfo() or {} + cprint(" -> %s", requireinfo.originstr) + end + end + + -- leave environment + environment.leave() end diff --git a/xmake/actions/require/list.lua b/xmake/actions/require/list.lua index 4246dc03e..8df9eb646 100644 --- a/xmake/actions/require/list.lua +++ b/xmake/actions/require/list.lua @@ -24,6 +24,7 @@ -- imports import("core.project.project") +import("core.base.task") import("package") import("repository") import("environment") diff --git a/xmake/actions/require/main.lua b/xmake/actions/require/main.lua index 3c3f64f7e..15d5efbf7 100644 --- a/xmake/actions/require/main.lua +++ b/xmake/actions/require/main.lua @@ -80,12 +80,12 @@ function main() -- search for the given packages from repositories elseif option.get("search") then - search(option.get("packages")) + search(option.get("requires")) -- show the given package info elseif option.get("info") then - info(option.get("packages")) + info(option.get("requires")) -- list all package dependencies elseif option.get("list") then |
