1 # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
19 # Parse and manage command line options
21 def initialize(args=ARGV)
37 def initialize_defaults
38 self[:config] = Dir["#{ENV["HOME"]}/.amazing/config.{rb,yml,yaml}"][0]
39 self[:loglevel] = "info"
41 self[:autoinclude] = true
46 @parser = OptionParser.new do |opts|
47 opts.on("-c", "--config FILE", "Configuration file (~/.amazing/config.{rb,yml,yaml})") do |config|
48 self[:config] = config
51 opts.on("-l", "--log-level LEVEL", "Severity threshold (info)") do |level|
52 self[:loglevel] = level
55 opts.on("-s", "--stop", "Stop the running amazing process") do
59 opts.on("-i", "--include SCRIPT", "Include a widgets script") do |script|
60 self[:include] << script
63 opts.on("--no-auto-include", "Don't auto include from ~/.amazing/widgets/") do
64 self[:autoinclude] = false
67 opts.on("-u", "--update [WIDGET]", "Update a widget and exit") do |widget|
69 self[:update] << widget
75 opts.on("-w", "--list-widgets [WIDGET]", "List available widgets or options and fields for a widget") do |widget|
76 self[:listwidgets] = widget || true
79 opts.on("-t", "--test-widget WIDGET [OPTIONS]", "Dump field values for a widget configured with inline YAML") do |widget|
83 opts.on("-h", "--help", "You're looking at it") do