cmd

package
v0.13.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2019 License: MIT Imports: 31 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// BuildModeProd indicates we are building for prod mode
	BuildModeProd = "prod"
	// BuildModeDebug indicates we are building for debug mode
	BuildModeDebug = "debug"
	// BuildModeBridge indicates we are building for bridge mode
	BuildModeBridge = "bridge"
)
View Source
const Version = "v0.13.3"

Version - Wails version

Variables

This section is empty.

Functions

func BuildApplication

func BuildApplication(binaryName string, forceRebuild bool, buildMode string, packageApp bool, projectOptions *ProjectOptions) error

BuildApplication will attempt to build the project based on the given inputs

func BuildFrontend

func BuildFrontend(buildCommand string) error

BuildFrontend runs the given build command

func CheckDependencies

func CheckDependencies(logger *Logger) (bool, error)

CheckDependencies will look for Wails dependencies on the system Errors are reported in error and the bool return value is whether the dependencies are all installed.

func CheckDependenciesSilent

func CheckDependenciesSilent(logger *Logger) (bool, error)

CheckDependenciesSilent checks for dependencies but only outputs if there's an error

func CheckMewn

func CheckMewn() (err error)

CheckMewn checks if mewn is installed and if not, attempts to fetch it

func CheckWindres

func CheckWindres() (err error)

CheckWindres checks if Windres is installed and if not, aborts

func DpkgInstalled

func DpkgInstalled(packageName string) (bool, error)

DpkgInstalled uses dpkg to see if a package is installed

func InstallBridge added in v0.11.7

func InstallBridge(caller string, projectDir string, projectOptions *ProjectOptions) error

InstallBridge installs the relevant bridge javascript library

func InstallFrontendDeps

func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forceRebuild bool, caller string) error

InstallFrontendDeps attempts to install the frontend dependencies based on the given options

func InstallGoDependencies

func InstallGoDependencies() error

InstallGoDependencies will run go get in the current directory

func PackageApplication

func PackageApplication(projectOptions *ProjectOptions) error

PackageApplication will attempt to package the application in a platform dependent way

func PacmanInstalled added in v0.12.1

func PacmanInstalled(packageName string) (bool, error)

PacmanInstalled uses pacman to see if a package is installed.

func Prompt

func Prompt(question string, defaultValue ...string) string

Prompt asks the user for a value

func PromptRequired

func PromptRequired(question string, defaultValue ...string) string

PromptRequired calls Prompt repeatedly until a value is given

func PromptSelection

func PromptSelection(question string, options []string, optionalDefaultValue ...int) int

PromptSelection asks the user to choose an option

func RpmInstalled added in v0.13.0

func RpmInstalled(packageName string) (bool, error)

RpmInstalled uses rpm to see if a package is installed

func ServeProject

func ServeProject(projectOptions *ProjectOptions, logger *Logger) error

ServeProject attempts to serve up the current project so that it may be connected to via the Wails bridge

func ValidateFrontendConfig

func ValidateFrontendConfig(projectOptions *ProjectOptions) error

ValidateFrontendConfig checks if the frontend config is valid

Types

type Action

type Action func() error

Action represents a function that gets calls when the command is called by the user

type Cli

type Cli struct {
	// contains filtered or unexported fields
}

Cli - The main application object

func NewCli

func NewCli(name, description string) *Cli

NewCli - Creates a new Cli application object

func (*Cli) BoolFlag

func (c *Cli) BoolFlag(name, description string, variable *bool) *Command

BoolFlag - Adds a boolean flag to the root command

func (*Cli) Command

func (c *Cli) Command(name, description string) *Command

Command - Adds a command to the application

func (*Cli) DefaultCommand

func (c *Cli) DefaultCommand(defaultCommand *Command) *Cli

DefaultCommand - Sets the given command as the command to run when no other commands given

func (*Cli) PreRun

func (c *Cli) PreRun(callback func(*Cli) error)

PreRun - Calls the given function before running the specific command

func (*Cli) PrintHelp

func (c *Cli) PrintHelp()

PrintHelp - Prints the application's help

func (*Cli) Run

func (c *Cli) Run(args ...string) error

Run - Runs the application with the given arguments

func (*Cli) StringFlag

func (c *Cli) StringFlag(name, description string, variable *string) *Command

StringFlag - Adds a string flag to the root command

func (*Cli) Version

func (c *Cli) Version(version string)

Version - Set the Application version string

type Command

type Command struct {
	Name             string
	CommandPath      string
	Shortdescription string
	Longdescription  string
	AppVersion       string
	SubCommands      []*Command
	SubCommandsMap   map[string]*Command

	ActionCallback Action
	App            *Cli
	Flags          *flag.FlagSet
	// contains filtered or unexported fields
}

Command represents a command that may be run by the user

func NewCommand

func NewCommand(name string, description string, app *Cli, parentCommandPath string) *Command

NewCommand creates a new Command

func (*Command) Action

func (c *Command) Action(callback Action) *Command

Action - Define an action from this command

func (*Command) BoolFlag

func (c *Command) BoolFlag(name, description string, variable *bool) *Command

BoolFlag - Adds a boolean flag to the command

func (*Command) Command

func (c *Command) Command(name, description string) *Command

Command - Defines a subcommand

func (*Command) LongDescription

func (c *Command) LongDescription(Longdescription string) *Command

LongDescription - Sets the long description for the command

func (*Command) PrintHelp

func (c *Command) PrintHelp()

PrintHelp - Output the help text for this command

func (*Command) Run

func (c *Command) Run(args []string) error

Run - Runs the Command with the given arguments

func (*Command) StringFlag

func (c *Command) StringFlag(name, description string, variable *string) *Command

StringFlag - Adds a string flag to the command

type DistroInfo

type DistroInfo struct {
	Distribution  LinuxDistribution
	Description   string
	Release       string
	Codename      string
	DistributorID string
}

DistroInfo contains all the information relating to a linux distribution

func GetLinuxDistroInfo

func GetLinuxDistroInfo() *DistroInfo

GetLinuxDistroInfo returns information about the running linux distribution

type FSHelper

type FSHelper struct {
}

FSHelper - Wrapper struct for File System utility commands

func NewFSHelper

func NewFSHelper() *FSHelper

NewFSHelper - Returns a new FSHelper

func (*FSHelper) CopyFile

func (fs *FSHelper) CopyFile(source, target string) error

CopyFile from source to target

func (*FSHelper) CreateFile added in v0.9.5

func (fs *FSHelper) CreateFile(filename string, data []byte) error

CreateFile creates a file at the given filename location with the contents set to the given data. It will create intermediary directories if needed.

func (*FSHelper) Cwd

func (fs *FSHelper) Cwd() string

Cwd returns the current working directory Aborts on Failure

func (*FSHelper) DirExists

func (fs *FSHelper) DirExists(path string) bool

DirExists - Returns true if the given path resolves to a directory on the filesystem

func (*FSHelper) FileExists

func (fs *FSHelper) FileExists(path string) bool

FileExists returns a boolean value indicating whether the given file exists

func (*FSHelper) FileMD5

func (fs *FSHelper) FileMD5(filename string) (string, error)

FileMD5 returns the md5sum of the given file

func (*FSHelper) GetSubdirs

func (fs *FSHelper) GetSubdirs(dir string) (map[string]string, error)

GetSubdirs will return a list of FQPs to subdirectories in the given directory

func (*FSHelper) LoadAsString

func (fs *FSHelper) LoadAsString(filename string) (string, error)

LoadAsString will attempt to load the given file and return its contents as a string

func (*FSHelper) MkDir

func (fs *FSHelper) MkDir(dir string) error

MkDir creates the given directory. Returns error on failure

func (*FSHelper) MkDirs

func (fs *FSHelper) MkDirs(fullPath string, mode ...os.FileMode) error

MkDirs creates the given nested directories. Returns error on failure

func (*FSHelper) RemoveFile

func (fs *FSHelper) RemoveFile(filename string) error

RemoveFile removes the given filename

func (*FSHelper) RemoveFiles

func (fs *FSHelper) RemoveFiles(files []string) error

RemoveFiles removes the given filenames

type GitHubHelper added in v0.13.0

type GitHubHelper struct {
}

GitHubHelper is a utility class for interacting with GitHub

func NewGitHubHelper added in v0.13.0

func NewGitHubHelper() *GitHubHelper

NewGitHubHelper returns a new GitHub Helper

func (*GitHubHelper) GetLatestPreRelease added in v0.13.0

func (g *GitHubHelper) GetLatestPreRelease() (result *SemanticVersion, err error)

GetLatestPreRelease gets the latest prerelease on GitHub

func (*GitHubHelper) GetLatestStableRelease added in v0.13.0

func (g *GitHubHelper) GetLatestStableRelease() (result *SemanticVersion, err error)

GetLatestStableRelease gets the latest stable release on GitHub

func (*GitHubHelper) GetVersionTags added in v0.13.0

func (g *GitHubHelper) GetVersionTags() ([]*SemanticVersion, error)

GetVersionTags gets the list of tags on the Wails repo It retuns a list of sorted tags in descending order

func (*GitHubHelper) IsValidTag added in v0.13.0

func (g *GitHubHelper) IsValidTag(tagVersion string) (bool, error)

IsValidTag returns true if the given string is a valid tag

type LinuxDistribution

type LinuxDistribution int

LinuxDistribution is of type int

const (
	// Unknown is the catch-all distro
	Unknown LinuxDistribution = iota
	// Ubuntu distribution
	Ubuntu
	// Arch linux distribution
	Arch
	// RedHat linux distribution
	RedHat
)

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger struct

func NewLogger

func NewLogger() *Logger

NewLogger creates a new logger!

func (*Logger) Error

func (l *Logger) Error(format string, a ...interface{})

Error - Outputs an Error message

func (*Logger) Green

func (l *Logger) Green(format string, a ...interface{})

Green - Outputs Green text

func (*Logger) PrintBanner

func (l *Logger) PrintBanner() error

PrintBanner prints the Wails banner before running commands

func (*Logger) PrintSmallBanner

func (l *Logger) PrintSmallBanner(message ...string)

PrintSmallBanner prints a condensed banner

func (*Logger) Red

func (l *Logger) Red(format string, a ...interface{})

Red - Outputs Red text

func (*Logger) SetErrorOnly

func (l *Logger) SetErrorOnly(errorOnly bool)

SetErrorOnly ensures that only errors are logged out

func (*Logger) White

func (l *Logger) White(format string, a ...interface{})

White - Outputs White text

func (*Logger) WhiteUnderline

func (l *Logger) WhiteUnderline(format string, a ...interface{})

WhiteUnderline - Outputs White text with underline

func (*Logger) Yellow

func (l *Logger) Yellow(format string, a ...interface{})

Yellow - Outputs yellow text

func (*Logger) YellowUnderline

func (l *Logger) YellowUnderline(format string, a ...interface{})

YellowUnderline - Outputs Yellow text with underline

func (*Logger) Yellowf

func (l *Logger) Yellowf(format string, a ...interface{})

Yellowf - Outputs yellow text without the newline

type PackageHelper

type PackageHelper struct {
	// contains filtered or unexported fields
}

PackageHelper helps with the 'wails package' command

func NewPackageHelper

func NewPackageHelper() *PackageHelper

NewPackageHelper creates a new PackageHelper!

func (*PackageHelper) Package

func (b *PackageHelper) Package(po *ProjectOptions) error

Package the application into a platform specific package

func (*PackageHelper) PackageWindows

func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error

PackageWindows packages the application for windows platforms

type Prerequisite

type Prerequisite struct {
	Name string
	Help string
	Path string
}

Prerequisite defines a Prerequisite!

type Prerequisites

type Prerequisites []*Prerequisite

Prerequisites is a list of things required to use Wails

func GetRequiredLibraries

func GetRequiredLibraries() (*Prerequisites, error)

GetRequiredLibraries returns a list of libraries (packages) required for the platform

func GetRequiredPrograms

func GetRequiredPrograms() (*Prerequisites, error)

GetRequiredPrograms returns a list of programs required for the platform

func (*Prerequisites) Add

func (p *Prerequisites) Add(prereq *Prerequisite)

Add given prereq object to list

type Program

type Program struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

Program - A struct to define an installed application/binary

func (*Program) GetFullPathToBinary

func (p *Program) GetFullPathToBinary() (string, error)

GetFullPathToBinary returns the full path the the current binary

func (*Program) Run

func (p *Program) Run(vars ...string) (stdout, stderr string, exitCode int, err error)

Run will execute the program with the given parameters Returns stdout + stderr as strings and an error if one occurred

type ProgramHelper

type ProgramHelper struct {
	// contains filtered or unexported fields
}

ProgramHelper - Utility functions around installed applications

func NewProgramHelper

func NewProgramHelper() *ProgramHelper

NewProgramHelper - Creates a new ProgramHelper

func (*ProgramHelper) FindProgram

func (p *ProgramHelper) FindProgram(programName string) *Program

FindProgram attempts to find the given program on the system.FindProgram Returns a struct with the name and path to the program

func (*ProgramHelper) InstallGoPackage

func (p *ProgramHelper) InstallGoPackage(packageName string) error

InstallGoPackage installs the given Go package

func (*ProgramHelper) IsInstalled

func (p *ProgramHelper) IsInstalled(programName string) bool

IsInstalled tries to determine if the given binary name is installed

func (*ProgramHelper) RunCommand

func (p *ProgramHelper) RunCommand(command string) error

RunCommand runs the given command

func (*ProgramHelper) RunCommandArray

func (p *ProgramHelper) RunCommandArray(args []string, dir ...string) error

RunCommandArray runs the command specified in the array

type ProjectHelper

type ProjectHelper struct {
	// contains filtered or unexported fields
}

ProjectHelper is a helper struct for managing projects

func NewProjectHelper

func NewProjectHelper() *ProjectHelper

NewProjectHelper creates a new Project helper struct

func (*ProjectHelper) GenerateProject

func (ph *ProjectHelper) GenerateProject(projectOptions *ProjectOptions) error

GenerateProject generates a new project using the options given

func (*ProjectHelper) LoadProjectConfig

func (ph *ProjectHelper) LoadProjectConfig(dir string) (*ProjectOptions, error)

LoadProjectConfig loads the project config from the given directory

func (*ProjectHelper) NewProjectOptions

func (ph *ProjectHelper) NewProjectOptions() *ProjectOptions

NewProjectOptions creates a new default set of project options

type ProjectOptions

type ProjectOptions struct {
	Name            string    `json:"name"`
	Description     string    `json:"description"`
	Author          *author   `json:"author,omitempty"`
	Version         string    `json:"version"`
	OutputDirectory string    `json:"-"`
	UseDefaults     bool      `json:"-"`
	Template        string    `json:"-"`
	BinaryName      string    `json:"binaryname"`
	FrontEnd        *frontend `json:"frontend,omitempty"`
	NPMProjectName  string    `json:"-"`
	// contains filtered or unexported fields
}

ProjectOptions holds all the options available for a project

func (*ProjectOptions) Defaults

func (po *ProjectOptions) Defaults()

Defaults sets the default project template

func (*ProjectOptions) LoadConfig

func (po *ProjectOptions) LoadConfig(projectDir string) error

LoadConfig loads the project configuration file from the given directory

func (*ProjectOptions) PromptForInputs

func (po *ProjectOptions) PromptForInputs() error

PromptForInputs asks the user to input project details

func (*ProjectOptions) WriteProjectConfig

func (po *ProjectOptions) WriteProjectConfig() error

WriteProjectConfig writes the project configuration into the project directory

type SemanticVersion added in v0.13.0

type SemanticVersion struct {
	Version *semver.Version
}

SemanticVersion is a struct containing a semantic version

func NewSemanticVersion added in v0.13.0

func NewSemanticVersion(version string) (*SemanticVersion, error)

NewSemanticVersion creates a new SemanticVersion object with the given version string

func (*SemanticVersion) IsGreaterThan added in v0.13.0

func (s *SemanticVersion) IsGreaterThan(version *SemanticVersion) (bool, error)

IsGreaterThan returns true if this version is greater than the given version

func (*SemanticVersion) IsGreaterThanOrEqual added in v0.13.0

func (s *SemanticVersion) IsGreaterThanOrEqual(version *SemanticVersion) (bool, error)

IsGreaterThanOrEqual returns true if this version is greater than or equal the given version

func (*SemanticVersion) IsPreRelease added in v0.13.0

func (s *SemanticVersion) IsPreRelease() bool

IsPreRelease returns true if it's a prerelease version

func (*SemanticVersion) IsRelease added in v0.13.0

func (s *SemanticVersion) IsRelease() bool

IsRelease returns true if it's a release version

func (*SemanticVersion) MainVersion added in v0.13.0

func (s *SemanticVersion) MainVersion() *SemanticVersion

MainVersion returns the main version of any version+prerelease+metadata EG: MainVersion("1.2.3-pre") => "1.2.3"

func (*SemanticVersion) String added in v0.13.0

func (s *SemanticVersion) String() string

type SemverCollection added in v0.13.0

type SemverCollection []*SemanticVersion

SemverCollection is a collection of SemanticVersion objects

func (SemverCollection) Len added in v0.13.0

func (c SemverCollection) Len() int

Len returns the length of a collection. The number of Version instances on the slice.

func (SemverCollection) Less added in v0.13.0

func (c SemverCollection) Less(i, j int) bool

Less is needed for the sort interface to compare two Version objects on the slice. If checks if one is less than the other.

func (SemverCollection) Swap added in v0.13.0

func (c SemverCollection) Swap(i, j int)

Swap is needed for the sort interface to replace the Version objects at two different positions in the slice.

type ShellHelper

type ShellHelper struct {
}

ShellHelper helps with Shell commands

func NewShellHelper

func NewShellHelper() *ShellHelper

NewShellHelper creates a new ShellHelper!

func (*ShellHelper) Run

func (sh *ShellHelper) Run(command string, vars ...string) (stdout, stderr string, err error)

Run the given command

func (*ShellHelper) RunInDirectory added in v0.12.3

func (sh *ShellHelper) RunInDirectory(dir string, command string, vars ...string) (stdout, stderr string, err error)

RunInDirectory runs the given command in the given directory

type SystemConfig

type SystemConfig struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

SystemConfig - Defines system wode configuration data

func NewSystemConfig

func NewSystemConfig(filename string) (*SystemConfig, error)

NewSystemConfig - Creates a new SystemConfig helper object

func (*SystemConfig) Save

func (sc *SystemConfig) Save(filename string) error

Save - Saves the system config to the given filename

type SystemHelper

type SystemHelper struct {
	// contains filtered or unexported fields
}

SystemHelper - Defines everything related to the system

func NewSystemHelper

func NewSystemHelper() *SystemHelper

NewSystemHelper - Creates a new System Helper

func (*SystemHelper) BackupConfig

func (s *SystemHelper) BackupConfig() (string, error)

BackupConfig attempts to backup the system config file

func (*SystemHelper) CheckInitialised

func (s *SystemHelper) CheckInitialised() error

CheckInitialised checks if the system has been set up and if not, runs setup

func (*SystemHelper) ConfigFileExists

func (s *SystemHelper) ConfigFileExists() bool

ConfigFileExists - Returns true if it does!

func (*SystemHelper) ConfigFileIsValid

func (s *SystemHelper) ConfigFileIsValid() bool

ConfigFileIsValid checks if the config file is valid

func (*SystemHelper) Initialise

func (s *SystemHelper) Initialise() error

Initialise attempts to set up the Wails system. An error is returns if there is a problem

func (*SystemHelper) LoadConfig

func (s *SystemHelper) LoadConfig() (*SystemConfig, error)

LoadConfig attempts to load the Wails system config

type Template

type Template struct {
	Name        string
	Path        string
	Description string
}

Template holds details about a Wails template

type TemplateDetails added in v0.9.5

type TemplateDetails struct {
	BasePath string
	Path     string
	Metadata *TemplateMetadata
}

TemplateDetails holds information about a specific template

type TemplateHelper

type TemplateHelper struct {
	TemplateList *TemplateList
	Files        *mewnlib.FileGroup
}

TemplateHelper is a utility object to help with processing templates

func NewTemplateHelper

func NewTemplateHelper() *TemplateHelper

NewTemplateHelper creates a new template helper

func (*TemplateHelper) InstallTemplate

func (t *TemplateHelper) InstallTemplate(projectPath string, projectOptions *ProjectOptions) error

InstallTemplate installs the template given in the project options to the project path given

type TemplateList added in v0.9.5

type TemplateList struct {
	// contains filtered or unexported fields
}

TemplateList is a list of available templates

func NewTemplateList added in v0.9.5

func NewTemplateList(filenames *mewnlib.FileGroup) *TemplateList

NewTemplateList creates a new TemplateList object

type TemplateMetadata added in v0.9.5

type TemplateMetadata struct {
	Name             string `json:"name"`
	ShortDescription string `json:"shortdescription"`
	Description      string `json:"description"`
	Install          string `json:"install"`
	Build            string `json:"build"`
	Author           string `json:"author"`
	Created          string `json:"created"`
	FrontendDir      string `json:"frontenddir"`
	Serve            string `json:"serve"`
	Bridge           string `json:"bridge"`
}

TemplateMetadata holds all the metadata for a Wails template

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL