A command-line tool with a simple/standardized way of adding new subcommands. I started making all of my command-line tools subcommands for Hero for a few reasons:
- so they are grouped together
- so that it doesn't clutter the global namespace or name-clash with any other unix commands
The ShellCommandable module adds a DSL with methods that make it really easy to add subcommands:
# new script that uses ShellCommandable
# file: example
#!/usr/bin/env ruby
require './lib/shell_commandable'
class MainCommand
include ShellCommandable
register_subcommand(:ls) {
system('ls -l')
}
end
MainCommand.run
# command-line
# $> example ls
The DSL that Subcommandable creates handles commands with the following properties:
- has subcommands
- has a separate task if no subcommands are given
- accepts a "dynamic" subcommand, for example...a Heroku App's name:
h heroku production-app restart
- for subcommands that echo a directory or something that you can not cd into
without making new
$SHELL
processes...copy the cd command or whatever command directly to the clipboard, that way we can just paste and the cmd is already there h ssh
authorize_key
- either gets it from the clipboard (pbpaste) or from a file the user passes incopy_key
- puts one of the existing public keys in the clipboard (pbcopy)hosts
- list hosts in ~/.ssh/configadd_host
- the user specifies the alias, connection stringgit@heroku.com:someapp.git
and then has the user select the key to use from a list...and it can automatically add it to~/.ssh/config