CLI

Wails comes with a CLI tool that allows you to generate, build and bundle your projects. It deals with the complexity of juggling Go and Javascript environments.

It has a number of commands:

Help

wails –help

This will output the cli help message with all the available commands and flags.

Setup

wails setup

The setup command does a number of things - it asks you for your name and email so that it can fill in project templates with your details. It also checks to see if your environment has the dependencies it needs and if not, try to suggest ways on how to install those dependencies.

Setup is also the default command so it can be invoked by simply running wails.

Your browser does not support the video tag.

Init

wails init

The init command builds out a new project based on a template of your choice. We curently support a basic Vue, Vuetify and React templates. The project will be built automatically after initialisation.

Basic Vue

This template consists of a frontend composed of Vue components, bundled together using Webpack. It makes a simple call to the backend.

Vuetify

This template consists of a frontend composed of Vuetify components, bundled together using Webpack. It makes a simple call to the backend.

React

This template consists of a frontend composed of React components, bundled together using Webpack. It makes a simple call to the backend.

Your browser does not support the video tag.

Serve

wails serve

When you run wails serve, it will compile up the backend and run it in headless mode. This allows you to develop the frontend using your standard tooling. When you run your app, it will connect to the backend at startup and make all your backend functions available to you.

We will cover this more in the tutorial.

Your browser does not support the video tag.

Build

wails build

The build command is the Wails equivalent of go build, however it does a number of things:

  • Installs frontend dependencies if needed
  • Performs a build of the frontend
  • Packs the frontend using Webpack
  • It downloads any Go dependencies that are required
  • It finally compiles and bundles everything into a single binary
Your browser does not support the video tag.

Build Flags

Here is a list of all available flags:

FlagDescription
-fForce rebuild of frontend dependencies
-dBuild application in Debug mode
-pPackage application after a successful build

The -p flag is currently supports OSX and Windows. On OSX, it bundles your binary into a .app file with the default icon. On Windows, it will generate the application resource files and compile it all into a ‘.exe’. When the -p flag is used, the packaging files are left available for editing. Any changes will be picked up by the next build (eg icon).

Update

wails update

This command does a check to see if the current version is the latest. If not, it will download and install the latest version. It is possible to also use it to install ‘prerelease’ versions by using the -pre flag. If a specific version is required, then it supports a -version flag.

Example: wails update -pre will update the latest prerelease version

Issue

wails issue

This command speeds up the process for submitting an issue to the Wails project. When you run the command, you will be asked to answer a couple of questions:

CLI - 图1

Wails then determines some environmental details such as it’s own version, opens a browser and fills in the default issue template.

CLI - 图2

Please note: you can edit the template as you feel fit before submitting.

You now have a good basis for your template. Running wails init will now give you your template as an option to install. When the project is generated using the template, it will create directories, copy non-template files then copy template files. Template files end in .template and will be treated as standard Go templates in which embedded codes are substituted with values in the Project Options.