Adjust the getenv API
The getenv call in sys/config was renamed to getenvs and now uses the splat operator so that arrays don't have to be passed in. A new function called getenv was added which takes a single argument and returns a single value back (for ease of use).
This commit is contained in:
@@ -37,7 +37,7 @@ class Config
|
||||
# Returns a hash of requested environment variables, along with their values.
|
||||
# If a requested value doesn't exist in the response, then the value wasn't found.
|
||||
#
|
||||
def getenv(var_names)
|
||||
def getenvs(*var_names)
|
||||
request = Packet.create_request('stdapi_sys_config_getenv')
|
||||
|
||||
var_names.each do |v|
|
||||
@@ -56,6 +56,13 @@ class Config
|
||||
return result
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the value of a single requested environment variable name
|
||||
#
|
||||
def getenv(var_name)
|
||||
getenvs(var_name)[var_name]
|
||||
end
|
||||
|
||||
#
|
||||
# Returns a hash of information about the remote computer.
|
||||
#
|
||||
|
||||
@@ -279,8 +279,11 @@ class Console::CommandDispatcher::Stdapi::Sys
|
||||
print_line("Server username: #{client.sys.config.getuid}")
|
||||
end
|
||||
|
||||
#
|
||||
# Get the value of one or more environment variables from the target.
|
||||
#
|
||||
def cmd_getenv(*args)
|
||||
vars = client.sys.config.getenv(args)
|
||||
vars = client.sys.config.getenvs(*args)
|
||||
|
||||
if vars.length == 0
|
||||
print_error("None of the specified environment variables were found/set.")
|
||||
|
||||
Reference in New Issue
Block a user