class CpSoButtons
The main application-class.
Public Class Methods
new(args)
click to toggle source
# File lib/cpsobuttons.rb, line 45 def initialize(args) # remove this, if you want win_bail_out $APP_NAME = self.class.name options = ArgParser.parse(args) if(!options.conf_dir) guess_conf_dir(options) end if(options.action) self.send(options.action, options) else UserIO::msg_missing_option end end
Public Instance Methods
method_missing(method, *args)
click to toggle source
# File lib/cpsobuttons.rb, line 61 def method_missing(method, *args) UserIO::msg_method_undefined(self.class.name, method.to_s) exit end
Private Instance Methods
copy(options)
click to toggle source
This method copies sections from the source- to the target-file. short names (e.g. tmfo16 -> pmfo16) and full ini-paths should be okay.
# File lib/cpsobuttons.rb, line 81 def copy(options) src = options.source trg = options.target section = options.section if(section) if(src && trg) if(src != trg) # Currently, only buttons can be copied. if(:buttons == section) FSObjects.copy_buttons(src, trg, section, options.conf_dir) else # TODO # FSObjects.copy(src, trg, section) end else UserIO::msg_cannot_copy('Source- and target-file are the same.') end else UserIO::msg_cannot_copy((src ? 'Target' : 'Source') << " not specified.") end else UserIO::msg_no_section_given('Copy what? (hint: copy buttons with -b)') end end
guess_conf_dir(options)
click to toggle source
If not given, try to read all information from files in the directory $DEF_CONF_DIR
# File lib/cpsobuttons.rb, line 69 def guess_conf_dir(options) if(Dir.exists?($DEF_CONF_DIR) ) options.conf_dir = $DEF_CONF_DIR UserIO::msg_info_conf_dir(options.conf_dir) else UserIO::msg_no_config("Where are those files? Use option '-c'") end end
list_all(options)
click to toggle source
lists all program-names and configuration-files.
# File lib/cpsobuttons.rb, line 106 def list_all(options) UserIO::msg_available_information list = FSObjects.complete(options.conf_dir) puts list puts end
list_conf_files(options)
click to toggle source
lists all existing configuration-files
# File lib/cpsobuttons.rb, line 121 def list_conf_files(options) UserIO::msg_list_configs list = FSObjects.read_config(options.conf_dir).sort.join("\n") puts list puts end
list_short_names(options)
click to toggle source
lists the short application designators which correspond to the existing configuration-files
# File lib/cpsobuttons.rb, line 114 def list_short_names(options) UserIO::msg_short_progs list = FSObjects.short_names(options.conf_dir).sort puts list puts end
win_bail_out()
click to toggle source
Exits the program if it is run on Windows.
# File lib/cpsobuttons.rb, line 128 def win_bail_out if $WIN UserIO.msg_win_bailout exit false end end