Skip to content

Commit 3c3d30c

Browse files
committed
query app info by id
1 parent 516abea commit 3c3d30c

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ $ md system
2626
* `lan`
2727
* `devices`
2828
* `apps`
29+
* `apps :appId` - 通过应用id,查询应用的最新信息
2930
* ...

Diff for: api/apps.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ type App struct {
44
Id string `json:"id"`
55
Name string `json:"name"`
66
Author string `json:"author"`
7-
Icon string `json:"icon"`
8-
Source string `json:"source"`
9-
Version string `json:"size"`
7+
Icon string `json:"icon,omitempty"`
8+
Source string `json:"source,omitempty"`
9+
Version string `json:"size,omitempty"`
1010
Size int `json:"size"`
11-
Chksum string `json:"chksum"`
12-
ReleaseDate string `json:"releaseDate"`
11+
IsRunning bool `json:"isRunning"`
12+
Chksum string `json:"chksum,omitempty"`
13+
ReleaseDate string `json:"releaseDate,omitempty"`
1314
InstallDate string `json:"installDate"`
14-
Description string `json:"description"`
15-
Instruction string `json:"instruction"`
15+
Description string `json:"description,omitempty"`
16+
Instruction string `json:"instruction,omitempty"`
1617
}
1718

1819
type Apps struct {

Diff for: apps.go

+26-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import (
88
)
99

1010
var cmdApps = cli.Command{
11-
Name: "apps",
12-
Usage: "List apps, show apps",
11+
Name: "apps",
12+
Usage: "List apps, show apps",
13+
Action: runApps,
1314
Subcommands: []cli.Command{
1415
{
1516
Name: "list",
@@ -19,6 +20,17 @@ var cmdApps = cli.Command{
1920
},
2021
}
2122

23+
func runApps(c *cli.Context) {
24+
args := c.Args()
25+
if len(args) == 0 {
26+
cli.ShowSubcommandHelp(c)
27+
return
28+
}
29+
appId := args.First()
30+
app := getAppInfoById(appId)
31+
fmt.Println(app)
32+
}
33+
2234
func runAppsList(c *cli.Context) {
2335
req, err := client.NewRequest("GET", "/plugin/installed_plugins")
2436
if err != nil {
@@ -29,3 +41,15 @@ func runAppsList(c *cli.Context) {
2941
err = req.ToJSON(&result)
3042
fmt.Println(result)
3143
}
44+
45+
func getAppInfoById(id string) api.App {
46+
req, err := client.NewRequest("GET", "/plugin/plugin_latest_info")
47+
if err != nil {
48+
fmt.Println(err)
49+
}
50+
req.SetCookie(config.Cookie)
51+
req.QueryString("id=" + id)
52+
var result api.App
53+
err = req.ToJSON(&result)
54+
return result
55+
}

0 commit comments

Comments
 (0)