Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat Gadget Tool Command Line Call


May 20, 2021 WeChat Mini Program Development Document


Table of contents


The developer tool provides both the command line and the HTTP service interface for external calls, and developers can sign in, preview, upload, and more through the command line or HTTP request indication tool.

The command line

The tools installed can be executed by calling the tools on the command line to log in, preview, upload, automate testing, and more. A call return code of 0 represents normal and an error at -1.

Where the command line tool is located:

macOS: slt; installation path/ Contents/Resources/app.nw/bin/cli

Windows: the installation path is the same as the .bat

1. The command line starts the tool

-o, --open (projectpath): Open the tool, if you don't have projectpath, just open the tool. I f you have project path, the items in the path are opened, refreshed automatically compiled each time they are performed, and the emulator and debugger are automatically opened. P rojectpath cannot be a relative path. The project path must contain the correctly formatted project.config.json with appid and projectname fields.

Example:

# 打开工具
cli -o
# 打开路径 /Users/username/demo 下的项目
cli -o base64@/Users/username/demo

2. The command line logs in

The command line provides two ways to log in: one is to transfer the login QR code to base64 to the user, allowing the user to integrate itself into their own system, and the other is to print the QR code on the command line.

-l, --login: Start login logic.

--login-qr-output (format(@path): Specifies the form of QR code output, format optional values include terminal (command line output), base64, image. I f there is a fill path, the result is output to the file for the specified path. I f path is not filled in, the result is output to the command line. If you do not use this option or if you do not fill in format, the default is command-line printing.

Example:

# 登录,在终端中打印登录二维码
cli -l
# 登录,在终端中打印登录 base64 形式的二维码
cli -l --login-qr-output base64
# 登录,二维码转成 base64 并存到文件 /Users/username/code.txt 
cli -l --login-qr-output base64@/Users/username/code.txt

3. Command line submit preview

You must be signed in when previewing, and if you're not, you'll be prompted to sign in first. T he previewed QR code can be printed on the command line or converted to base64. Project configurations such as ES6 are read from project.config.json.

-p, --preview project_root: Preview the code, project_root specify the root path of the project.

--preview-qr-output (format(@path): Specify the QR code output form, semantically the same option for login-qr-output.

Example:

# 预览,在终端中打印登录二维码
cli -p /Users/username/demo
# 预览,二维码转成 base64 并存到文件 /Users/username/code.txt
cli -p /Users/username/demo --preview-qr-output base64@/Users/username/code.txt

4. The command line upload code

You must be signed in when you upload your code, and if you're not, you'll be prompted to sign in first.

The information required to upload the code includes the project root, version number, and optional version notes.

-u, --upload slt;version@project_root: Upload code, version specifies version number, project_root specifies project root path.

--upload-desc and lt;desc>: Notes when uploading code.

Example:

# 上传路径 /Users/username/demo 下的项目,指定版本号为 1.0.0,版本备注为 initial release
cli -u 1.0.0@/Users/username/demo --upload-desc 'initial release'

5. Support for automated testing

-t, --test , project_root: Submit automated tests, project_root specify the project root path.

Example:

# 提交测试路径 /Users/username/demo 下的项目
cli -t /Users/username/demo