indent
[sfa.git] / sfa / client / sfi.py
index 9cb40aa..7b06363 100755 (executable)
@@ -309,17 +309,22 @@ def create_cmd_parser(command, additional_cmdargs = None):
 
    parser = OptionParser(usage="sfi [sfi_options] %s [options] %s" \
       % (command, cmdargs[command]))
+
    if command in ("resources"):
       parser.add_option("-f", "--format", dest="format",type="choice",
            help="display format (dns|ip|rspec)",default="rspec",
-           choices=("dns","ip","rspec"))
+           choices=("dns","ip","xml"))
    if command in ("list", "show", "remove"):
       parser.add_option("-t", "--type", dest="type",type="choice",
            help="type filter (user|slice|sa|ma|node|aggregate)",
            choices=("user","slice","sa","ma","node","aggregate", "all"),
            default="all")
    if command in ("show", "list", "resources"):
-      parser.add_option("-o", "--output", dest="file",
+        # This option is for all commands
+        parser.add_option("-f", "--format", dest="format", type="choice",
+           help="display format (text|xml)",default="text",
+           choices=("text","xml"))
+        parser.add_option("-o", "--output", dest="file",
            help="output XML to file", metavar="FILE", default=None)
    if command in ("delegate"):
       parser.add_option("-u", "--user",
@@ -439,7 +444,11 @@ def show(opts, args):
            record = AuthorityRecord(dict = record)
        else:
            record = GeniRecord(dict = record)
-       record.dump() 
+
+       if (opts.format=="text"):
+            record.dump() 
+       else:
+            print record.save_to_string()
    
    if opts.file:
        save_records_to_file(opts.file, records)