Getting Started¶
This guide walks you through installing Asgard, creating your first .loki task file, and running tasks from the command line.
Installation¶
Verify the Installation¶
Create Your First Task File¶
Every Asgard project needs a .loki file at its root. This hidden file is both the project root marker (Asgard searches upward from CWD to find it) and the entry point for your tasks.
Open .loki in your editor and add a task:
Note
The Tasks class is pre-defined by the gem as class Tasks < Asgard::Base. You just reopen it — no require or superclass declaration needed.
Run Your Task¶
See all available tasks:
See help for a specific task:
Add a Parameter¶
Positional parameters are declared directly in the method signature. Document them in the desc usage string:
class Tasks
desc "greet NAME", "Greet someone by name"
def greet(name = "World")
puts "Hello, #{name}!"
end
end
Add an Option¶
Use method_option (alias: option) to declare named flags:
class Tasks
desc "greet NAME", "Greet someone by name"
option :shout, aliases: "-s", type: :boolean, desc: "Uppercase the greeting"
def greet(name = "World")
msg = options[:shout] ? "HELLO, #{name.upcase}!" : "Hello, #{name}!"
puts msg
end
end
Multi-Loki Structure¶
A large Asgard project might look like this:
myproject/
.loki ← root marker and entry point (may be empty or contain tasks)
build.loki ← build-related and library dependency-related tasks
deploy.loki ← deployment tasks
qa.loki ← test and lint tasks
Each *.loki file reopens class Tasks. To load them, pass --auto-load to the asgard command — they are loaded alphabetically before .loki. See Task Files for full details.
Built-in Flags¶
Every task automatically has three flags available, defined as class_option on Tasks:
| Flag | Description |
|---|---|
--version |
Print the Asgard version and exit |
--debug |
Set $DEBUG = true before the task runs |
--verbose |
Set $VERBOSE = true before the task runs |
Inside a task body, use the debug? and verbose? predicates:
Next Steps¶
- Defining Tasks — parameters, options, aliases, long_desc
- Dependencies — sequential, parallel, and mixed dependency graphs
- Variables — share values across tasks
- Shell Helpers —
sh,shebang, and polyglot scripts - Subcommands — group related tasks under a namespace
- Examples — working
.lokifiles for every feature