Configuration scaffolding
[amazing.git] / lib / amazing / cli.rb
blob37ba276686e84f7e84292df1988e7c9e74c5d19d
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.
15 require 'amazing'
16 require 'amazing/cli/commands'
17 require 'amazing/cli/helpers'
18 require 'amazing/cli/initializers'
19 require 'fileutils'
20 require 'logger'
21 require 'thread'
22 require 'timeout'
23 require 'yaml'
25 module Amazing
27   # Command line interface runner
28   #
29   #   CLI.new(ARGV).run
30   class CLI
31     include Initializers
32     include Helpers
33     include Commands
35     def initialize(args=ARGV)
36       @args = args
37       initialize_threads
38       initialize_encoding
39       initialize_logger
40       initialize_options
41       initialize_display
42       initialize_awesome
43       initialize_exit
44     end
46     def run
47       parse_options
48       cmd_show_help
49       cmd_scaffold
50       set_loglevel
51       cmd_stop_process
52       load_scripts
53       cmd_list_widgets
54       cmd_test_widget
55       parse_config
56       wait_for_sockets
57       cmd_explicit_updates
58       stop_process
59       save_pid
60       set_traps
61       update_non_interval
62       cmd_main
63       join_threads
64     end
65   end
66 end