projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
closes #4024
[arvados.git]
/
sdk
/
cli
/
bin
/
arv
diff --git
a/sdk/cli/bin/arv
b/sdk/cli/bin/arv
index 2acc626752b3d958b39797436fbbf8afb70581a5..533ea39eb7b27c2d96f391e1bc47c2cb8d599fc9 100755
(executable)
--- a/
sdk/cli/bin/arv
+++ b/
sdk/cli/bin/arv
@@
-113,10
+113,17
@@
def init_config
end
end
end
end
-subcommands = %w(keep pipeline tag ws edit create)
+
+subcommands = %w(copy create edit keep pipeline run tag ws)
def check_subcommands client, arvados, subcommand, global_opts, remaining_opts
case subcommand
def check_subcommands client, arvados, subcommand, global_opts, remaining_opts
case subcommand
+ when 'create'
+ arv_create client, arvados, global_opts, remaining_opts
+ when 'edit'
+ arv_edit client, arvados, global_opts, remaining_opts
+ when 'copy', 'tag', 'ws', 'run'
+ exec `which arv-#{subcommand}`.strip, *remaining_opts
when 'keep'
@sub = remaining_opts.shift
if ['get', 'put', 'ls', 'normalize'].index @sub then
when 'keep'
@sub = remaining_opts.shift
if ['get', 'put', 'ls', 'normalize'].index @sub then
@@
-143,14
+150,6
@@
def check_subcommands client, arvados, subcommand, global_opts, remaining_opts
puts "Available methods: run"
end
abort
puts "Available methods: run"
end
abort
- when 'tag'
- exec `which arv-tag`.strip, *remaining_opts
- when 'ws'
- exec `which arv-ws`.strip, *remaining_opts
- when 'edit'
- arv_edit client, arvados, global_opts, remaining_opts
- when 'create'
- arv_create client, arvados, global_opts, remaining_opts
end
end
end
end
@@
-163,7
+162,7
@@
def command_exists?(command)
ENV['PATH'].split(':').each {|folder| File.executable?(File.join(folder, command))}
end
ENV['PATH'].split(':').each {|folder| File.executable?(File.join(folder, command))}
end
-def run_editor tmp, global_opts
+def run_editor tmp
_file
, global_opts
need_edit = true
while need_edit
pid = Process::fork
need_edit = true
while need_edit
pid = Process::fork
@@
-176,14
+175,14
@@
def run_editor tmp, global_opts
puts "Could not find any editor to use, please set $VISUAL or $EDITOR to your desired editor."
exit 1
end
puts "Could not find any editor to use, please set $VISUAL or $EDITOR to your desired editor."
exit 1
end
- exec editor, tmp.path
+ exec editor, tmp
_file
.path
else
Process.wait pid
end
if $?.exitstatus == 0
else
Process.wait pid
end
if $?.exitstatus == 0
- tmp.open
- newcontent = tmp.read()
+ tmp
_file
.open
+ newcontent = tmp
_file
.read()
newobj = {}
begin
newobj = {}
begin
@@
-207,7
+206,7
@@
def run_editor tmp, global_opts
yn = $stdin.read 1
end
if yn == 'n' or yn == 'N'
yn = $stdin.read 1
end
if yn == 'n' or yn == 'N'
- arv_edit_save_tmp tmp
+ arv_edit_save_tmp tmp
_file
abort
end
end
abort
end
end
@@
-288,11
+287,11
@@
def arv_edit client, arvados, global_opts, remaining_opts
content = results.to_yaml
end
content = results.to_yaml
end
- tmp = Tempfile.new([uuid, "." + global_opts[:format]])
- tmp.write(content)
- tmp.close
+ tmp
_file
= Tempfile.new([uuid, "." + global_opts[:format]])
+ tmp
_file
.write(content)
+ tmp
_file
.close
- newobj = run_editor tmp, global_opts
+ newobj = run_editor tmp
_file
, global_opts
begin
if newobj != results
begin
if newobj != results
@@
-302,7
+301,7
@@
def arv_edit client, arvados, global_opts, remaining_opts
begin
result = client.execute(:api_method => eval(api_method),
:parameters => {"uuid" => uuid},
begin
result = client.execute(:api_method => eval(api_method),
:parameters => {"uuid" => uuid},
- :body => { rsc.singularize => dumped },
+ :body
_object
=> { rsc.singularize => dumped },
:authenticated => false,
:headers => {
authorization: 'OAuth2 '+ENV['ARVADOS_API_TOKEN']
:authenticated => false,
:headers => {
authorization: 'OAuth2 '+ENV['ARVADOS_API_TOKEN']
@@
-311,14
+310,14
@@
def arv_edit client, arvados, global_opts, remaining_opts
puts "Error communicating with server, error was #{e}"
puts "Update body was:"
puts dumped
puts "Error communicating with server, error was #{e}"
puts "Update body was:"
puts dumped
- arv_edit_save_tmp tmp
+ arv_edit_save_tmp tmp
_file
abort
end
begin
results = JSON.parse result.body
rescue JSON::ParserError => e
abort
end
begin
results = JSON.parse result.body
rescue JSON::ParserError => e
- arv_edit_save_tmp tmp
+ arv_edit_save_tmp tmp
_file
abort "Failed to parse server response:\n" + e.to_s
end
abort "Failed to parse server response:\n" + e.to_s
end
@@
-326,14
+325,14
@@
def arv_edit client, arvados, global_opts, remaining_opts
puts "Update failed. Server responded #{result.response.status}: #{results['errors']} "
puts "Update body was:"
puts dumped
puts "Update failed. Server responded #{result.response.status}: #{results['errors']} "
puts "Update body was:"
puts dumped
- arv_edit_save_tmp tmp
+ arv_edit_save_tmp tmp
_file
abort
end
else
puts "Object is unchanged, did not update."
end
ensure
abort
end
else
puts "Object is unchanged, did not update."
end
ensure
- tmp.close(true)
+ tmp
_file
.close(true)
end
exit 0
end
exit 0
@@
-393,11
+392,11
@@
def arv_create client, arvados, global_opts, remaining_opts
content = newobj.to_yaml
end
content = newobj.to_yaml
end
- tmp = Tempfile.new(["", ".#{global_opts[:format]}"])
- tmp.write(content)
- tmp.close
+ tmp
_file
= Tempfile.new(["", ".#{global_opts[:format]}"])
+ tmp
_file
.write(content)
+ tmp
_file
.close
- newobj = run_editor tmp, global_opts
+ newobj = run_editor tmp
_file
, global_opts
begin
api_method = 'arvados.' + rsc + '.create'
begin
api_method = 'arvados.' + rsc + '.create'
@@
-414,7
+413,7
@@
def arv_create client, arvados, global_opts, remaining_opts
begin
results = JSON.parse result.body
rescue JSON::ParserError => e
begin
results = JSON.parse result.body
rescue JSON::ParserError => e
- arv_edit_save_tmp tmp
+ arv_edit_save_tmp tmp
_file
abort "Failed to parse server response:\n" + e.to_s
end
abort "Failed to parse server response:\n" + e.to_s
end
@@
-422,18
+421,18
@@
def arv_create client, arvados, global_opts, remaining_opts
puts "Create failed. Server responded #{result.response.status}: #{results['errors']} "
puts "Create body was:"
puts dumped
puts "Create failed. Server responded #{result.response.status}: #{results['errors']} "
puts "Create body was:"
puts dumped
- arv_edit_save_tmp tmp
+ arv_edit_save_tmp tmp
_file
abort
end
begin
puts "Created object #{results['uuid']}"
rescue
abort
end
begin
puts "Created object #{results['uuid']}"
rescue
- arv_edit_save_tmp tmp
+ arv_edit_save_tmp tmp
_file
abort "Unexpected response:\n#{results}"
end
ensure
abort "Unexpected response:\n#{results}"
end
ensure
- tmp.close(true)
+ tmp
_file
.close(true)
end
exit 0
end
exit 0
@@
-673,7
+672,7
@@
when
else
result = client.execute(:api_method => eval(api_method),
:parameters => request_parameters,
else
result = client.execute(:api_method => eval(api_method),
:parameters => request_parameters,
- :body => request_body,
+ :body
_object
=> request_body,
:authenticated => false,
:headers => {
authorization: 'OAuth2 '+ENV['ARVADOS_API_TOKEN']
:authenticated => false,
:headers => {
authorization: 'OAuth2 '+ENV['ARVADOS_API_TOKEN']