Module: Refuge
- Defined in:
- lib/refuge.rb,
lib/refuge/options.rb
Defined Under Namespace
Modules: Commands, Native
Constant Summary
collapse
- LIBBASE =
'refuge/'
- LIBBASE_COMMANDS =
LIBBASE + 'commands/'
- LIBBASE_NATIVE =
LIBBASE + 'native/'
- LIBBASE_UTILS =
LIBBASE + 'utils/'
- DEFAULT_COMMAND =
'help'
- EXIT_CODES =
Standard exit code mappings.
{
:ok => [ 0, '' ],
:general => [ 1, 'General error' ],
:os_not_supported => [ 10, 'Your operating system is not yet supported' ],
:native_not_impl => [ 20, 'A native interface feature is not implemented' ],
:cmd_not_impl => [ 21, 'A command feature is not implemented' ],
}
- DEFAULT_SETTINGS =
{
:help => false,
:verbose => false
}
- COMMON_OPTIONS =
{
:verbose => 'Run with verbose output.'
}
- @@options =
OpenStruct.new DEFAULT_SETTINGS
Class Method Summary
collapse
Class Method Details
.load_libs(base, names) ⇒ Object
Loads a set of library scripts under a common base path.
56
57
58
59
60
|
# File 'lib/refuge.rb', line 56
def load_libs ( base, names )
names.each do | elem |
require base + elem
end
end
|
.option_parser ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/refuge/options.rb', line 44
def option_parser
@@option_parser ||= OptionParser.new do | op |
op.banner = "Usage: #{ $0 } [common-options] command [options]"
op.separator ''
op.separator 'Common Options:'
op.on( '-?', '--help', 'Show quick usage information.' ) do | x |
@@options.help = x
end
COMMON_OPTIONS.sort.each do | tag, desc |
op.on( "-#{ tag.to_s[ 0, 1 ] }", "--[no-]#{ tag }", desc ) do | x |
@@options[ tag ] = x
end
end
end
end
|
.options ⇒ Object
42
|
# File 'lib/refuge/options.rb', line 42
def options; @@options; end
|
.update_options(table) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/refuge/options.rb', line 64
def update_options ( table )
table.each_pair do | key, value |
@@options[ key ] = value
end
end
|