This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Howl.lua
79 lines (67 loc) · 1.94 KB
/
Howl.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
--- Core script for Howl
-- @script Howl
local options = ArgParse.Options({...})
options
:Option "verbose"
:Alias "v"
:Description "Print verbose output"
options
:Option "time"
:Alias "t"
:Description "Display the time taken for tasks"
options
:Option "trace"
:Description "Print a stack trace on errors"
options
:Option "help"
:Alias "?"
:Alias "h"
:Description "Print this help"
local tasks = Runner.Factory()
local currentTask = options:Arguments()[1]
options:OnChanged(function(options)
Utils.SetVerbose(options:Get "verbose")
tasks.ShowTime = options:Get "time"
tasks.Traceback = options:Get "trace"
if options:Get "help" then
currentTask = "help"
end
end)
-- Locate the howl file
local howlFile, currentDirectory = HowlFile.FindHowl()
HowlFile.CurrentDirectory = currentDirectory
Utils.Verbose("Found HowlFile at " .. fs.combine(currentDirectory, howlFile))
-- SETUP TASKS
-- Basic list tasks
tasks:Task "list" (function()
tasks:ListTasks()
end):Description "Lists all the tasks"
tasks:Task "help" (function()
Utils.Print("Howl [options] [task]")
Utils.PrintColor(colors.orange, "Tasks:")
tasks:ListTasks(" ")
Utils.PrintColor(colors.orange, "\nOptions:")
options:Help(" ")
end):Description "Print out a detailed usage for Howl"
-- If no other task exists run this
tasks:Default(function()
Utils.PrintError("No default task exists.")
Utils.Verbose("Use 'Tasks:Default' to define a default task")
Utils.PrintColor(colors.orange, "Choose from: ")
tasks:ListTasks(" ")
end)
-- Setup an environment
local environment = HowlFile.SetupEnvironment({
-- Core globals
CurrentDirectory = currentDirectory,
Tasks = tasks,
Options = options,
-- Helper functions
Verbose = Utils.Verbose,
Log = Utils.VerboseLog,
File = function(...) return fs.combine(currentDirectory, ...) end,
})
-- Load the file
environment.dofile(howlFile)
-- Run the task
tasks:Run(currentTask)