[ARVADOS] updated: 81707e982741b7ab100156c3390ae245b1e9f777

git at public.curoverse.com git at public.curoverse.com
Fri Jan 17 17:35:24 EST 2014


Summary of changes:
 sdk/cli/bin/arv |   56 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 35 insertions(+), 21 deletions(-)

       via  81707e982741b7ab100156c3390ae245b1e9f777 (commit)
       via  5331a594c86695ef360c2d03e1c42ffc00d213b8 (commit)
      from  88b9bd0d114334e1b73ebd620f6524f17b9a48db (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 81707e982741b7ab100156c3390ae245b1e9f777
Merge: 5331a59 88b9bd0
Author: Tim Pierce <twp at curoverse.com>
Date:   Fri Jan 17 17:35:34 2014 -0500

    Merge branch 'master' of git.clinicalfuture.com:arvados


commit 5331a594c86695ef360c2d03e1c42ffc00d213b8
Author: Tim Pierce <twp at curoverse.com>
Date:   Fri Jan 17 17:33:00 2014 -0500

    Updated `arv' command line format options. Default now generates JSON. (refs #1889)
    
    Replaced --pretty, --json, --uuid, --yaml, --human with
    --format={json,uuid,yaml}, and added --short for --format=uuid.
    
    Default output format is now JSON (pretty-printed).

diff --git a/sdk/cli/bin/arv b/sdk/cli/bin/arv
index 96353c6..3fd3c57 100755
--- a/sdk/cli/bin/arv
+++ b/sdk/cli/bin/arv
@@ -188,25 +188,36 @@ end
 
 def parse_arguments(discovery_document)
   resource_types = Array.new()
-  resource_types << '--help'
   discovery_document["resources"].each do |k,v|
     resource_types << k.singularize
   end
 
   global_opts = Trollop::options do
-    banner "arvados cli client"
+    banner "arv: the Arvados CLI tool"
     opt :dry_run, "Don't actually do anything", :short => "-n"
-    opt :verbose, "Print some things on stderr", :short => "-v"
-    opt :uuid, "Return the UUIDs of the objects in the response, one per line (default)", :short => nil
-    opt :json, "Return the entire response received from the API server, as a JSON object", :short => "-j"
-    opt :human, "Return the response received from the API server, as a JSON object with whitespace added for human consumption", :short => "-h"
-    opt :pretty, "Synonym of --human", :short => nil
-    opt :yaml, "Return the response received from the API server, in YAML format", :short => "-y"
+    opt :verbose, "Print some things on stderr"
+    opt :format,
+        "Set the output format. Must be one of json (default), yaml or uuid.",
+        :type => :string,
+        :default => 'json'
+    opt :short, "Return only UUIDs (equivalent to --format=uuid)"
+    opt :resources, "Display list of resources known to this Arvados instance."
+    conflicts :short, :format
     stop_on resource_types
   end
-  
+
+  unless %w(json yaml uuid).include?(global_opts[:format])
+    $stderr.puts "#{$0}: --format must be one of json, yaml or uuid."
+    $stderr.puts "Use #{$0} --help for more information."
+    abort
+  end
+
+  if global_opts[:short]
+    global_opts[:format] = 'uuid'
+  end
+
   resource = ARGV.shift
-  if resource == '--help' or not resource_types.include?(resource)
+  if global_opts[:resources] or not resource_types.include?(resource)
     help_resources(discovery_document, resource)
   end
 
@@ -323,18 +334,21 @@ if results["errors"] then
   abort "Error: #{results["errors"][0]}"
 end
 
-if global_opts[:human] or global_opts[:pretty] then
+case global_opts[:format]
+when 'json'
   puts Oj.dump(results, :indent => 1)
-elsif global_opts[:yaml] then
+when 'yaml'
   puts results.to_yaml
-elsif global_opts[:json] then
-  puts Oj.dump(results)
-elsif results["items"] and results["kind"].match /list$/i
-  results['items'].each do |i| puts i['uuid'] end
-elsif results['uuid'].nil?
-  abort("Response did not include a uuid:\n" +
-        Oj.dump(results, :indent => 1) +
-        "\n")
 else
-  puts results['uuid']
+  if results["items"] and results["kind"].match /list$/i
+    results['items'].each do |i| puts i['uuid'] end
+  elsif results['uuid'].nil?
+    abort("Response did not include a uuid:\n" +
+          Oj.dump(results, :indent => 1) +
+          "\n")
+  else
+    puts results['uuid']
+  end
 end
+
+

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list