Class: LaunchdTools::Cmd2LaunchdCli
- Inherits:
-
Object
- Object
- LaunchdTools::Cmd2LaunchdCli
- Defined in:
- lib/launchd_tools/cmd2launchd_cli.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Instance Method Summary collapse
-
#initialize(args) ⇒ Cmd2LaunchdCli
constructor
A new instance of Cmd2LaunchdCli.
- #run ⇒ Object
- #show_usage ⇒ Object
Constructor Details
#initialize(args) ⇒ Cmd2LaunchdCli
Returns a new instance of Cmd2LaunchdCli.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/launchd_tools/cmd2launchd_cli.rb', line 7 def initialize(args) if args.empty? show_usage exit 0 elsif args.length == 1 case args.first when "--help" show_usage exit 0 when "-h" show_usage exit 0 when "--version" puts LaunchdTools::VERSION exit 0 end end @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
6 7 8 |
# File 'lib/launchd_tools/cmd2launchd_cli.rb', line 6 def args @args end |
Instance Method Details
#run ⇒ Object
31 32 33 34 35 |
# File 'lib/launchd_tools/cmd2launchd_cli.rb', line 31 def run plist = LaunchdPlist.new plist.add_program_args(args) puts plist.to_s end |
#show_usage ⇒ Object
27 28 29 |
# File 'lib/launchd_tools/cmd2launchd_cli.rb', line 27 def show_usage puts "Usage: #{$0} command [arg1] [arg2]" end |