Class: OSDN::CLI::Command::Vars
- Inherits:
-
Base
- Object
- Base
- OSDN::CLI::Command::Vars
show all
- Defined in:
- lib/osdn/cli.rb
Instance Attribute Summary
Attributes inherited from Base
#credential, #format, #logger
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#credential_path, #initialize, #load_credential, #load_variables, #set_client_token, #set_credential, #update_token, #update_variables, #write_credential, #write_variables
Class Method Details
.description ⇒ Object
213
214
215
|
# File 'lib/osdn/cli.rb', line 213
def self.description
"Get/set request environment variable."
end
|
Instance Method Details
#help ⇒ Object
208
209
210
211
|
# File 'lib/osdn/cli.rb', line 208
def help
puts "#{$0} vars show [name] -- Show current variable"
puts "#{$0} vars set <name> <value> -- Save variable to .osdn.vars"
end
|
#run ⇒ Object
177
178
179
180
|
# File 'lib/osdn/cli.rb', line 177
def run
subcommand = ARGV.shift ||'show'
self.send subcommand
end
|
#set ⇒ Object
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
# File 'lib/osdn/cli.rb', line 191
def set
name, value = ARGV.shift, ARGV.shift
if !name || name.empty?
logger.fatal "Missing variable name"
help
exit
end
if !value || value.empty?
logger.fatal "Missing variable value"
help
exit
end
vars = load_variables('.', false)
vars[name] = value
write_variables vars
end
|
#show ⇒ Object
182
183
184
185
186
187
188
189
|
# File 'lib/osdn/cli.rb', line 182
def show
name = ARGV.shift
if name
puts load_variables[name]
else
pp load_variables
end
end
|