-
Notifications
You must be signed in to change notification settings - Fork 1
Setting Contexts
mosop edited this page Nov 27, 2016
·
4 revisions
The context is a main concept in the library. A context has several attributes, command names, arguments, working directories..., etc.
Contexts can be nested. For example, you can specify a base directory and relative directories to the base directory.
cmd = Run::Command.new(chdir: "/path/to/base")
cmd.run "pwd", chdir: "relative" # => prints "/path/to/base/relative"
cmd.run "pwd", chdir: "../sibling" # => prints "/path/to/sibling"
cmd.run "pwd", chdir: "/path/to/absolute" # => prints "/path/to/absolute"
You can nest contexts using command groups, ad infinitum.
cg = Run::CommandGroup.new(chdir: "/path/to/base") do |g|
g.group(chdir: "foo") do |g|
g.group(chdir: "bar") do |g|
g.group(chdir: "baz") do |g|
# ...
end
end
end
end