Documentation
¶
Overview ¶
Package rizla contains the source code of the rizla project
Index ¶
- Variables
- func Add(proj ...*Project)
- func DefaultGoMatcher(fullname string) bool
- func DefaultOnReload(p *Project) func(string)
- func DefaultOnReloaded(p *Project) func(string)
- func DefaultWatcher(abs string) bool
- func Len() int
- func RemoveAll()
- func Run(sources map[string][]string)
- func RunWith(watcher Watcher, sources map[string][]string, delayOnDetect time.Duration)
- func Stop()
- type MatcherFunc
- type Project
- type Watcher
- type WatcherChangeListener
- type WatcherErrorListener
Constants ¶
This section is empty.
Variables ¶
var DefaultDisableProgramRerunOutput = false
DefaultDisableProgramRerunOutput a long name but, it disables the output of the program's 'messages' after the first successfully run for each of the projects the project iteral can be override this value. set to true to disable the program's output when reloads
var DefaultWalkLoopSleep = 1350 * time.Second
DefaultWalkLoopSleep it's the sleep time of the loop when --walk flag is used(`filepath#Walk`). Defaults to 1.3 second.
var OnReloadScripts []string
OnReloadScripts simple file names which will execute a script, i.e `./on_reload.sh` or `./on_reload.bat` or even `service supervisor restart` on windows, it will just execute that based on the operating system, nothing crazy here, they are filled by the cli but they can be customized by the source as well.
If contains whitespaces, after the first whitespace they are the command's flags (if not a script file).
var ( // Out is the logger which prints watcher errors and information. // // Change its printer's Output (io.Writer) by `Out.SetOutput(io.Writer)`. Out = golog.New().SetOutput(os.Stdout) )
Functions ¶
func DefaultGoMatcher ¶
DefaultGoMatcher is the default Matcher for the Project iteral
func DefaultOnReload ¶
DefaultOnReload fired when file has changed and reload going to happens
func DefaultOnReloaded ¶
DefaultOnReloaded fired when reload has been finished. Defaults to noOp.
func DefaultWatcher ¶
DefaultWatcher is the default Watcher for the Project iteral allows all subdirs except .git, node_modules and vendor
func RemoveAll ¶
func RemoveAll()
RemoveAll clears the current projects, doesn't stop them if running
func Run ¶
Run same as RunWith but runs with the default file system watcher which is the fsnotify (watch over file system's signals) or the last used with RunWith.
It's a map of main files and their arguments, if any.
func RunWith ¶ added in v0.1.1
RunWith starts the repeat of the build-run-watch-reload task of all projects receives optional parameters which can be the main source file of the project(s) you want to add, they can work nice with .Add(project) also, so dont worry use it.
First receiver is the type of watcher second (optional) parameter(s) are the directories of the projects.
it's optional because they can be added with the .Add(NewProject) before the RunWith.
Types ¶
type MatcherFunc ¶
MatcherFunc returns whether the file should be watched for the reload
type Project ¶
type Project struct { // optional Name for the project Name string // MainFile is the absolute path of the go project's main file source. MainFile string // The application's name, usually is the MainFile withotu the extension. // At the future we may provide a way for custom naming which will be used on the "go build -o" flag. AppName string Args []string // The Output destination (sent by rizla and your program) Out *golog.Logger // The Err Output destination (sent on rizla errors and your program's errors) Err *golog.Logger // Watcher accepts subdirectories by the watcher // executes before the watcher starts, // if return true, then this (absolute) subdirectory is watched by watcher // the default accepts all subdirectories but ignores the ".git", "node_modules" and "vendor" Watcher MatcherFunc Matcher MatcherFunc // AllowReloadAfter skip reload on file changes that made too fast from the last reload // minimum allowed duration is 3 seconds. AllowReloadAfter time.Duration // AllowRunAfter it accepts the file changes // but it waits "x" duration for the reload to happen. AllowRunAfter time.Duration // OnReload fires when when file has been changed and rizla is going to reload the project // the parameter is the changed file name OnReload func(string) // OnReloaded fires when rizla finish with the reload // the parameter is the changed file name OnReloaded func(string) // DisableRuntimeDir set to true to disable adding subdirectories into the watcher, when a folder created at runtime // set to true to disable the program's output when reloads // defaults to false DisableRuntimeDir bool // DisableProgramRerunOutput a long name but, it disables the output of the program's 'messages' after the first successfully run // defaults to false DisableProgramRerunOutput bool // contains filtered or unexported fields }
Project the struct which contains the necessary fields to watch and reload(rerun) a go project
func NewProject ¶
NewProject returns a simple project iteral which doesn't needs argument parameters and has the default file matcher ( which is valid if you want to reload only on .Go files).
You can change all of its fields before the .Run function.
type Watcher ¶ added in v0.1.1
type Watcher interface { // OnChange registers an event listener which fires when a file change occurs. OnChange(WatcherChangeListener) // OnError registers an event listener which fires when a watcher error occurs. OnError(WatcherErrorListener) // Loop starts the watching and the loop. Loop() // Stop terminates the watcher. Stop() }
Watcher a common interface which file system watchers should implement.
func WatcherFromFlag ¶ added in v0.1.1
WatcherFromFlag returns a new Watcher based on a string flah. This method keeps the watchers in the same spot.
Note: this is why the internal watchers are not exported.
type WatcherChangeListener ¶ added in v0.1.1
WatcherChangeListener the form the OnChage event listener. Receives the project which the change is valid (see Project.AllowReloadAfter) and a second parameter which is the relative path to the changed file or directory.
type WatcherErrorListener ¶ added in v0.1.1
type WatcherErrorListener func(error)
WatcherErrorListener the form the OnError event listener.