Module: Rbcli::Configurate

Defined in:
lib/rbcli/configurate.rb,
lib/rbcli/autoupdate/autoupdate.rb,
lib/rbcli/stateful_systems/configuratestorage.rb

Class Method Summary collapse

Class Method Details

.allow_json_output(allow_json) ⇒ Object



62
63
64
# File 'lib/rbcli/configurate.rb', line 62

def self.allow_json_output allow_json
	@data[:allow_json] = allow_json
end

.autoupdate(gem: nil, github_repo: nil, access_token: nil, enterprise_hostname: nil, force_update: false) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/rbcli/autoupdate/autoupdate.rb', line 2

def self.autoupdate gem: nil, github_repo: nil, access_token: nil, enterprise_hostname: nil, force_update: false
	raise StandardError.new "Autoupdater can not have both a gem and git target defined. Please pick one." if gem and giturl
	raise StandardError.new "Only one autoupdater can be defined." if @data[:autoupdater]
	if gem
		#Rbcli::Autoupdate::GemUpdater.save_defaults
		@data[:autoupdater] = Rbcli::Autoupdate::GemUpdater.new gem, force_update
	else
		Rbcli::Autoupdate::GithubUpdater.save_defaults
		@data[:autoupdater] = Rbcli::Autoupdate::GithubUpdater.new github_repo, access_token, enterprise_hostname, force_update
	end
	@data[:autoupdater].show_message if @data[:autoupdater].update_available?
end

.config_default(*params) ⇒ Object



58
59
60
# File 'lib/rbcli/configurate.rb', line 58

def self.config_default *params
	Rbcli::Config::add_default *params
end

.config_defaults(filename) ⇒ Object



54
55
56
# File 'lib/rbcli/configurate.rb', line 54

def self.config_defaults filename
	Rbcli::Config::add_defaults filename
end

.config_userfile(*params) ⇒ Object



49
50
51
52
# File 'lib/rbcli/configurate.rb', line 49

def self.config_userfile *params
	Rbcli::Config::set_userfile *params
	@data[:config_userfile] = params[0]
end

.configurationObject

Data Retrieval



97
98
99
# File 'lib/rbcli/configurate.rb', line 97

def self.configuration
	@data
end

.default_action(&block) ⇒ Object



77
78
79
# File 'lib/rbcli/configurate.rb', line 77

def self.default_action &block
	@data[:default_action] = block
end

.description(desc) ⇒ Object



37
38
39
# File 'lib/rbcli/configurate.rb', line 37

def self.description desc
	@data[:description] = desc
end

.first_run(halt_after_running: false, &block) ⇒ Object



89
90
91
92
# File 'lib/rbcli/configurate.rb', line 89

def self.first_run halt_after_running: false, &block
	@data[:halt_after_first_run] = halt_after_running
	@data[:first_run] = block
end

.log_level(level) ⇒ Object



41
42
43
# File 'lib/rbcli/configurate.rb', line 41

def self.log_level level
	Rbcli::Logger::save_defaults level: level
end

.log_target(target) ⇒ Object



45
46
47
# File 'lib/rbcli/configurate.rb', line 45

def self.log_target target
	Rbcli::Logger::save_defaults target: target
end

.me(&block) ⇒ Object



17
18
19
20
# File 'lib/rbcli/configurate.rb', line 17

def self.me &block
	@self_before_instance_eval = eval "self", block.binding
	instance_eval &block
end

.option(name, description, type: :boolean, default: nil, required: false, permitted: nil) ⇒ Object



66
67
68
69
70
71
72
73
74
75
# File 'lib/rbcli/configurate.rb', line 66

def self.option name, description, type: :boolean, default: nil, required: false, permitted: nil
	default ||= false if (type == :boolean || type == :bool || type == :flag)
	@data[:options][name.to_sym] = {
			description: description,
			type: type,
			default: default,
			required: required,
			permitted: permitted
	}
end

.post_hook(&block) ⇒ Object



85
86
87
# File 'lib/rbcli/configurate.rb', line 85

def self.post_hook &block
	@data[:post_hook] = block
end

.pre_hook(&block) ⇒ Object



81
82
83
# File 'lib/rbcli/configurate.rb', line 81

def self.pre_hook &block
	@data[:pre_hook] = block
end

.scriptname(name) ⇒ Object

DSL Functions



29
30
31
# File 'lib/rbcli/configurate.rb', line 29

def self.scriptname name
	@data[:scriptname] = name
end

.storage(&block) ⇒ Object



2
3
4
# File 'lib/rbcli/stateful_systems/configuratestorage.rb', line 2

def self.storage &block
	Rbcli::ConfigurateStorage.configure &block
end

.version(vsn) ⇒ Object



33
34
35
# File 'lib/rbcli/configurate.rb', line 33

def self.version vsn
	@data[:version] = vsn
end