Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ubuntu:18.04
RUN apt-get update && apt-get install wget -y
RUN wget https://github.com/ucloud/ucloud-cli/releases/download/0.1.20/ucloud-cli-linux-0.1.20-amd64.tgz
RUN tar -zxf ucloud-cli-linux-0.1.20-amd64.tgz -C /usr/local/bin/
RUN echo "complete -C $(which ucloud) ucloud" >> ~/.bashrc
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export VERSION=0.1.20
export VERSION=0.1.21

.PHONY : build
build:
go install && mv ${GOPATH}/bin/ucloud-cli /usr/local/bin/ucloud
.PHONY : install
install:
go build -i -v -mod=vendor -o out/ucloud main.go
cp out/ucloud /usr/local/bin

.PHONY : build_mac
build_mac:
Expand All @@ -25,7 +26,3 @@ build_windows:
.PHONY : build_all
build_all: build_mac build_linux build_windows

.PHONY : install
install:
go build -o out/ucloud main.go
cp out/ucloud /usr/local/bin
69 changes: 55 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,99 @@
The UCloud CLI provides a unified command line interface to UCloud services. It works on Golang SDK based on UCloud OpenAPI and supports Linux, macOS and Windows.
https://docs.ucloud.cn/software/cli/index

## Installing ucloud-cli
## Installing ucloud-cli on macOS or Linux

**Using Homebrew(Preferred)**

The [Homebrew](https://docs.brew.sh/Installation) package manager may be used on macOS, Linux and Windows Subsystem for Linux (WSL).
The [Homebrew](https://docs.brew.sh/Installation) package manager may be used on macOS and Linux.
It could install ucloud-cli and its dependencies automatically by running command below.

```
$ brew install ucloud
brew install ucloud
```

If you have installed ucloud-cli already and want to upgrade to the latest version, just run:

```
$ brew upgrade ucloud
brew upgrade ucloud
```

If you come across some errors during the installation via homebrew, please update the homebrew first and try again.

```
$ brew update
brew update
```

If the error is still unresolved, try the following command for help.

```
$ brew doctor
brew doctor
```

**Building from source**

If you have installed git and golang on your platform, you can fetch the source code of ucloud cli from github and complie it by yourself.

```
$ git clone https://github.com/ucloud/ucloud-cli.git
$ cd ucloud-cli
$ make install
git clone https://github.com/ucloud/ucloud-cli.git
cd ucloud-cli
make install
```

**Downloading binary release**

Vist the [Releases page](https://github.com/ucloud/ucloud-cli/releases) of ucloud cli, and find the appropriate archive for your operating system and architecture.
Vist the [releases page](https://github.com/ucloud/ucloud-cli/releases) of ucloud cli, and find the appropriate archive for your operating system and architecture.
Download the archive , check the shasum256 hashcode and extract it to your $PATH

For example
```
curl -OL https://github.com/ucloud/ucloud-cli/releases/download/0.1.14/ucloud-cli-macosx-0.1.14-amd64.tgz
echo "6953232b20f3474973cf234218097006a2e0d1d049c115da6c0e09c103762d4d *ucloud-cli-macosx-0.1.14-amd64.tgz" | shasum -c
tar zxf ucloud-cli-macosx-0.1.14-amd64.tgz -C /usr/local/bin/
curl -OL https://github.com/ucloud/ucloud-cli/releases/download/0.1.20/ucloud-cli-macosx-0.1.20-amd64.tgz
echo "6953232b20f3474973cf234218097006a2e0d1d049c115da6c0e09c103762d4d *ucloud-cli-macosx-0.1.20-amd64.tgz" | shasum -c
tar zxf ucloud-cli-macosx-0.1.20-amd64.tgz -C /usr/local/bin/
```

## Enabling Shell Auto-Completion
## Installing ucloud cli on Windows

**Building from source**

Download the source code of ucloud cli from [releases page](https://github.com/ucloud/ucloud-cli/releases). You can also download it by running ```git clone https://github.com/ucloud/ucloud-cli.git```
Ensure you have git installed, because go will download packages using git. Go to the directory of the source code, and then compile the source code by running "go build -mod=vendor -o ucloud.exe"
After that add ucloud.exe to your environment variable PATH. You could follow [this document](https://www.java.com/en/download/help/path.xml) if you don't know how to do.
Open CMD Terminal and run ```ucloud --version ``` to test installation.


**Downloading binary release**

Vist the [releases page](https://github.com/ucloud/ucloud-cli/releases) of ucloud cli, and find the appropriate archive for your operating system and architecture.
Download the archive , and extract it. Add binary file ucloud.exe to your environment variable PATH following [this document](https://www.java.com/en/download/help/path.xml)

## Using ucloud cli in a Docker container
If you have installed docker on your platform, pull the docker image embeded ucloud cli by follow command.
```
docker pull uhub.service.ucloud.cn/ucloudcli/ucloud-cli:0.1.20
```

The docker image was built by the Dockerfile as follow.
```
FROM ubuntu:18.04
RUN apt-get update && apt-get install wget -y
RUN wget https://github.com/ucloud/ucloud-cli/releases/download/0.1.20/ucloud-cli-linux-0.1.20-amd64.tgz
RUN tar -zxf ucloud-cli-linux-0.1.20-amd64.tgz -C /usr/local/bin/
RUN echo "complete -C $(which ucloud) ucloud" >> ~/.bashrc #enable auto completion
```

Create a docker container named ucloud-cli using the docker image your have pulled by following command.

```
docker run --name ucloud-cli -it -d uhub.service.ucloud.cn/ucloudcli/ucloud-cli:0.1.20
```
Run bash command in ucloud-cli container, and then you could play with ucloud cli.

```
docker exec -it ucloud-cli bash
```

## Enabling Shell Auto-Completion for bash or zsh shell user.

UCloud CLI also has auto-completion support. It can be set up so that if you partially type a command and then press TAB, the rest of the command is automatically filled in.

Expand Down
Loading