7204: Minor refactoring of methods supporting `arv get` test cases.
[arvados.git] / sdk / cli / bin / arv
index cf1e732d19bf05a6291f7ecde3c6c46ed5790496..ccdd8a8c12bc077295f336be97c1f96d30cbfb3a 100755 (executable)
@@ -85,14 +85,14 @@ def init_config
 end
 
 
-subcommands = %w(copy create edit keep pipeline run tag view ws)
+subcommands = %w(copy create edit get keep pipeline run tag ws)
 
 def exec_bin bin, opts
-  @bin_path = `which #{bin}`.strip
-  if @bin_path.empty?
+  bin_path = `which #{bin}`.strip
+  if bin_path.empty?
     raise "#{bin}: command not found"
   end
-  exec @bin_path, *opts
+  exec bin_path, *opts
 end
 
 def check_subcommands client, arvados, subcommand, global_opts, remaining_opts
@@ -101,8 +101,8 @@ def check_subcommands client, arvados, subcommand, global_opts, remaining_opts
     arv_create client, arvados, global_opts, remaining_opts
   when 'edit'
     arv_edit client, arvados, global_opts, remaining_opts
-  when 'view'
-    arv_view client, arvados, global_opts, remaining_opts
+  when 'get'
+    arv_get client, arvados, global_opts, remaining_opts
   when 'copy', 'tag', 'ws', 'run'
     exec_bin "arv-#{subcommand}", remaining_opts
   when 'keep'
@@ -185,6 +185,8 @@ def edit_and_commit_object initial_obj, tmp_stem, global_opts, &block
                    Oj.load(newcontent)
                  when 'yaml'
                    YAML.load(newcontent)
+                 else
+                   abort "Unrecognized format #{global_opts[:format]}"
                  end
 
         yield newobj
@@ -343,11 +345,11 @@ def arv_edit client, arvados, global_opts, remaining_opts
   exit 0
 end
 
-def arv_view client, arvados, global_opts, remaining_opts
+def arv_get client, arvados, global_opts, remaining_opts
   uuid = remaining_opts.shift
   if uuid.nil? or uuid == "-h" or uuid == "--help"
     puts head_banner
-    puts "Usage: arv view [uuid] [fields...]\n\n"
+    puts "Usage: arv get [uuid] [fields...]\n\n"
     puts "Fetch the specified Arvados object, select the specified fields, \n"
     puts "and print a text representation (json or yaml, use --format).\n"
     exit 255