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
237
238
239
|
# File 'lib/osdn/cli.rb', line 237
def self.description
"Get/set request environment variable."
end
|
Instance Method Details
#help ⇒ Object
232
233
234
235
|
# File 'lib/osdn/cli.rb', line 232
def help
puts "#{$0} vars show [name] -- Show current variable"
puts "#{$0} vars set <name> <value> -- Save variable to .osdn.vars"
end
|
#run ⇒ Object
201
202
203
204
|
# File 'lib/osdn/cli.rb', line 201
def run
subcommand = ARGV.shift ||'show'
self.send subcommand
end
|
#set ⇒ Object
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
# File 'lib/osdn/cli.rb', line 215
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
206
207
208
209
210
211
212
213
|
# File 'lib/osdn/cli.rb', line 206
def show
name = ARGV.shift
if name
puts load_variables[name]
else
pp load_variables
end
end
|