#
shortcut
Optional
Defines a shortcut string that will be expanded before running anything. Note that this operates on the ARGV level. This is useful for creating short strings that expand to longer command lines.
title 'Admin Tools'
usage 'deploy [--build --env ENV]'
option '--build, -b', 'Build before deploying'
option '--env, -e ENV', 'Specify environment to deploy to [default: stage]'
shortcut 'go', 'deploy --build --env production'
action 'deploy' do |args|
env = args['--env']
say 'Building...' if args['--build']
say "Deploying to #{env}"
end
$ run --help
Admin Tools
Usage:
run deploy [--build --env ENV]
run (--help | -h)
Options:
--build, -b
Build before deploying
--env, -e ENV
Specify environment to deploy to [default: stage]
--help, -h
Show this message
Shortcuts:
go deploy --build --env production
$ run go
Building...
Deploying to production
Since these shortcuts are expanded as if the user has typed the longer command line, this feature can also be used to access commands in imported files.
title 'Admin Tools'
import 'server'
shortcut 's', 'server start'
action 'ping' do |args|
say 'PONG'
end
summary 'Server commands'
action 'start' do
say 'starting server'
end
action 'stop' do
say 'stopping server'
end
$ run --help
Admin Tools
Usage:
run ping
run server
run [COMMAND] (--help | -h)
Commands:
server
Server commands
Options:
--help, -h
Show this message
Shortcuts:
s server start
$ run s
starting server