Skip to content

Commit 4c20b04

Browse files
committed
Merge branch 'pre-release' into support-glide
2 parents 0a3256b + 5ea684d commit 4c20b04

File tree

12 files changed

+117
-217
lines changed

12 files changed

+117
-217
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# CHANGE LOG
22

3+
### 3.0.1 Final Version
4+
5+
- support `version` command
6+
- fix `--dryrun` flag bugs
7+
-
8+
39
### 3.0.0 GA Version
410

511
- refactoring cli package design, support composite flag with fields
612
- refactoring openapi package design, make it more extensible
713
- support `--quiet` flag
8-
- support `--dry-run` flag
14+
- support `--dryrun` flag
915
- support `aliyun oss --profile xxx`
1016

1117
### 0.81

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export VERSION=3.0.0
1+
export VERSION=3.0.1
22

33
all: build
44
publish: build build_mac build_linux build_windows

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
The Alibaba Cloud CLI is an open source tool, you can get the latest version from [GitHub](https://github.com/aliyun/aliyun-cli).
77

8-
This version is a new version built on Go. The new CLI is in the testing phase. If you want to use the old version (built on Alibaba Cloud Python SDK), click [here](https://github.com/aliyun/aliyun-cli/tree/python_final).
8+
This version is a new version built on Go. If you want to use the old version (built on Alibaba Cloud Python SDK), click [here](https://github.com/aliyun/aliyun-cli/tree/python_final).
99

1010
## Introduction
1111

@@ -23,17 +23,11 @@ You can install Alibaba Cloud CLI either through the installer or the source cod
2323

2424
Download the installer, then extract the installer. You can move the extracted `aliyun` executable file to the `/usr/local/bin` directory or add it to the `$PATH`.
2525

26-
Download link: (3.0.0 GA)
26+
Download link: (3.0.1)
2727

28-
- [Mac](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-macosx-3.0.0-amd64.tgz)
29-
- [Linux](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-linux-3.0.0-amd64.tgz)
30-
- [Windows (64 bit)](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-windows-3.0.0-amd64.zip)
31-
32-
Download link: (0.80 Beta)
33-
34-
- [Mac](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-macosx-0.80-amd64.tgz)
35-
- [Linux](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-linux-0.80-amd64.tgz)
36-
- [Windows (64 bit)](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-windows-0.80-amd64.zip)
28+
- [Mac](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-macosx-3.0.1-amd64.tgz)
29+
- [Linux](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-linux-3.0.1-amd64.tgz)
30+
- [Windows (64 bit)](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-windows-3.0.1-amd64.zip)
3731

3832
- **Compile source code**
3933

README_zh.md

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
阿里云命令行工具(Alibaba Cloud Command Line Interface)是开源项目,您可以从[Github](https://github.com/aliyun/aliyun-cli)上获取最新版本的CLI。
55

6-
该版本的CLI为Go语言重构版本,目前处于**BETA**发布中,如果您想使用原有的Python版本,请切换到[Python分支](https://github.com/aliyun/aliyun-cli/tree/python_final)
6+
该版本的CLI为Go语言重构版本,如果您想使用原有的Python版本,请切换到[Python分支](https://github.com/aliyun/aliyun-cli/tree/python_final)
77

88
## 简介
99

@@ -22,17 +22,11 @@
2222

2323
阿里云CLI工具下载、解压后即可使用,支持Mac, Linux, Windows平台(x64版本)。 您可以将解压的`aliyun`可执行文件移至`/usr/local/bin`目录下,或添加到`$PATH`中。
2424

25-
下载链接如下 (3.00 GA):
25+
下载链接如下 (3.0.1):
2626

27-
- [Mac](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-macosx-3.00-amd64.tgz)
28-
- [Linux](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-linux-3.00-amd64.tgz)
29-
- [Windows (64 bit)](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-windows-3.0.0-amd64.zip)
30-
31-
下载链接如下: (0.80 Beta)
32-
33-
- [Mac](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-macosx-0.80-amd64.tgz)
34-
- [Linux](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-linux-0.80-amd64.tgz)
35-
- [Windows (64 bit)](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-windows-0.80-amd64.zip)
27+
- [Mac](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-macosx-3.0.1-amd64.tgz)
28+
- [Linux](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-linux-3.0.1-amd64.tgz)
29+
- [Windows (64 bit)](http://aliyun-cli.oss-cn-hangzhou.aliyuncs.com/aliyun-cli-windows-3.0.1-amd64.zip)
3630

3731
- **编译源码**
3832

@@ -172,4 +166,65 @@ $ aliyun newproduct --version 2018-01-01 --endpoint newproduct.aliyuncs.com --pa
172166
- `--version`: 指定API的版本,你可以在API文档中找到版本号,如ECS的版本号是`2014-05-26`
173167
- `--endpoint`: 指定产品的接入地址,一般产品接入地址是`product.aliyuncs.com`,或`product.en-central-1.aliyuncs.com`,请参考各产品的API文档。
174168

175-
- `--waiter timeout=xxx`
169+
#### 使用`--output`参数
170+
171+
阿里云产品的查询接口会返回json结构化数据,不方便阅读。例如:
172+
173+
```
174+
$ aliyun ecs DescribeInstances
175+
```
176+
177+
执行以上命令将得到以下json结果:
178+
179+
```
180+
{
181+
"PageNumber": 1,
182+
"TotalCount": 2,
183+
"PageSize": 10,
184+
"RequestId": "2B76ECBD-A296-407E-BE17-7E668A609DDA",
185+
"Instances": {
186+
"Instance": [
187+
{
188+
"ImageId": "ubuntu_16_0402_64_20G_alibase_20171227.vhd",
189+
"InstanceTypeFamily": "ecs.xn4",
190+
"VlanId": "",
191+
"InstanceId": "i-12345678912345678123",
192+
"Status": "Stopped",
193+
//omit some fields
194+
},
195+
Instance": [
196+
{
197+
"ImageId": "ubuntu_16_0402_64_20G_alibase_20171227.vhd",
198+
"InstanceTypeFamily": "ecs.xn4",
199+
"VlanId": "",
200+
"InstanceId": "i-abcdefghijklmnopqrst",
201+
"Status": "Running",
202+
//omit some fields
203+
},
204+
]
205+
}
206+
}
207+
```
208+
209+
可以使用`--output`参数提取结果中感兴趣的字段,并进行表格化输出。例如:
210+
211+
212+
```
213+
$ aliyun ecs DescribeInstances --output cols=InstanceId,Status
214+
```
215+
216+
执行以上命令将得到以下形式的结果:
217+
```
218+
InstanceId | Status
219+
---------- | ------
220+
i-12345678912345678123 | Stopped
221+
i-abcdefghijklmnopqrst | Running
222+
```
223+
224+
在使用`--output`参数时,必须指定以下参数:
225+
226+
- `--cols`: 表格的列名,需要与json数据中的字段相对应。如ECS DescribeInstances 接口返回结果中的字段`InstanceId` 以及 `Status`
227+
228+
可选参数:
229+
- `--rows`: 通过[jmespath](http://jmespath.org/)查询语句来指定表格行在json结果中的数据来源。当查询语句具有`Instances.Instance[]`的形式时,可以省略该参数。
230+

cli/version.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
*/
44
package cli
55

6-
import "strings"
6+
import (
7+
"strings"
8+
"github.com/aliyun/aliyun-cli/i18n"
9+
"fmt"
10+
)
711

812
//
913
// This variable is replaced in compile time
@@ -14,4 +18,16 @@ var (
1418

1519
func GetVersion() string {
1620
return strings.Replace(Version, " ", "-", -1)
21+
}
22+
23+
func NewVersionCommand() *Command {
24+
return &Command{
25+
Name: "version",
26+
Short: i18n.T("print current version", "打印当前版本号"),
27+
Hidden: true,
28+
Run: func(ctx *Context, args []string) error {
29+
fmt.Printf("%s\n", Version)
30+
return nil
31+
},
32+
}
1733
}

main/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func main() {
6262
rootCmd.AddSubCommand(configureCommand)
6363
// rootCmd.AddSubCommand(command.NewTestCommand())
6464
rootCmd.AddSubCommand(lib.NewOssCommand())
65+
rootCmd.AddSubCommand(cli.NewVersionCommand())
6566
rootCmd.AddSubCommand(cli.NewAutoCompleteCommand())
6667
rootCmd.Execute(os.Args[1:])
6768
}

openapi/caller.go

Lines changed: 0 additions & 182 deletions
This file was deleted.

openapi/commando.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ func (c *Commando) processInvoke(ctx *cli.Context, productCode string, apiOrMeth
8787
return err
8888
}
8989

90-
// process --dry-run
90+
// process --dryrun
9191
if DryRunFlag.IsAssigned() {
92-
fmt.Printf("Dry-run with request: \n------------------------------------\n%v\n",
93-
invoker.getRequest())
92+
invoker.getRequest().TransToAcsRequest()
93+
invoker.getClient().BuildRequestWithSigner(invoker.getRequest(), nil)
94+
fmt.Printf("Skip invoke in dry-run mode, request is:\n------------------------------------\n%s\n",
95+
invoker.getRequest().String())
9496
return nil
9597
}
9698

0 commit comments

Comments
 (0)