(command.CommandList
  children: [
    (command.ShFunction
      name: usage
      body: 
        (BraceGroup
          children: [
            (command.Simple
              words: [{<cat>}]
              redirects: [
                (redir
                  op: <Id.Redir_DLess '<<'>
                  loc: (redir_loc.Fd fd:0)
                  arg: 
                    (redir_param.HereDoc
                      here_begin: {<EOF>}
                      here_end_span_id: 86
                      stdin_parts: [
                        <
'Usage: kythe-index.sh (--all | [--extract] [--analyze] [--postprocess] [--serve])\n'
                        >
                        <
'                      [--graphstore path] [--serving_table path] [--serving_addr host:port]\n'
                        >
                        <'                      [--bazel-root path] [--kythe-release path]\n'>
                        <'\n'>
                        <
'Utility script to run the Kythe toolset over the Bazel repository.  This script can run each\n'
                        >
                        <
'component of Kythe separately with the --extract, --analyze, --postprocess, and --serve flags or all\n'
                        >
                        <'together with the --all flag.\n'>
                        <'\n'>
                        <
'Paths to output artifacts are controlled with the --graphstore and --serving_table flags.  Their\n'
                        >
                        <'defaults are /tmp/gs.bazel and /tmp/serving.bazel, respectively.\n'>
                        <'\n'>
                        <
'The --serving_addr flag controls the listening address of the Kythe http_server.  It\'s default is\n'
                        >
                        <'localhost:8888.\n'>
                        <'\n'>
                        <
'The --bazel-root and --kythe-release flags control which Bazel repository to index and at what path\n'
                        >
                        <'are the Kythe tools.  They default to '>
                        ($ Id.VSub_DollarName '$PWD')
                        <' and /opt/kythe, respectively.\n'>
                      ]
                    )
                )
              ]
              do_fork: T
            )
          ]
        )
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (command.DBracket
                      expr: 
                        (bool_expr.Binary
                          op_id: Id.BoolBinary_eq
                          left: {($ Id.VSub_Pound '$#')}
                          right: {<0>}
                        )
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [(C {<usage>}) (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})]
          spids: [90 103]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (command.Pipeline
                      children: [
                        (command.Simple
                          words: [{<command>} {<-v>} {<bazel>}]
                          redirects: [
                            (redir
                              op: <Id.Redir_Great '>'>
                              loc: (redir_loc.Fd fd:1)
                              arg: {<'/dev/null'>}
                            )
                          ]
                          do_fork: T
                        )
                      ]
                      negated: T
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (command.Simple
              words: [{<echo>} {(DQ <'ERROR: bazel not found on your PATH'>)}]
              redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})]
              do_fork: T
            )
            (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
          ]
          spids: [116 130]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:KYTHE_RELEASE)
          op: assign_op.Equal
          rhs: {<'/opt/kythe'>}
          spids: [150]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:BAZEL_ROOT)
          op: assign_op.Equal
          rhs: {(DQ ($ Id.VSub_DollarName '$PWD'))}
          spids: [153]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:GRAPHSTORE)
          op: assign_op.Equal
          rhs: {<'/tmp/gs.bazel'>}
          spids: [159]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:SERVING_TABLE)
          op: assign_op.Equal
          rhs: {<'/tmp/serving.bazel'>}
          spids: [162]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:SERVING_ADDR)
          op: assign_op.Equal
          rhs: {<localhost> <Id.Lit_Colon ':'> <8888>}
          spids: [165]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:EXTRACT)
          op: assign_op.Equal
          rhs: (word.Empty)
          spids: [171]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:ANALYZE)
          op: assign_op.Equal
          rhs: (word.Empty)
          spids: [173]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:POSTPROCESS)
          op: assign_op.Equal
          rhs: (word.Empty)
          spids: [175]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:SERVE)
          op: assign_op.Equal
          rhs: (word.Empty)
          spids: [177]
        )
      ]
    )
    (command.WhileUntil
      keyword: <Id.KW_While while>
      cond: 
        (condition.Shell
          commands: [
            (command.Sentence
              child: 
                (command.DBracket
                  expr: 
                    (bool_expr.Binary
                      op_id: Id.BoolBinary_gt
                      left: {($ Id.VSub_Pound '$#')}
                      right: {<0>}
                    )
                )
              terminator: <Id.Op_Semi _>
            )
          ]
        )
      body: 
        (command.DoGroup
          children: [
            (command.Case
              to_match: {(DQ ($ Id.VSub_Number '$1'))}
              arms: [
                (case_arm
                  pat_list: [{<--help>} {<-h>}]
                  action: [(C {<usage>}) (command.ControlFlow token:<Id.ControlFlow_Exit exit>)]
                  spids: [205 208 216 -1]
                )
                (case_arm
                  pat_list: [{<--all>} {<-a>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:EXTRACT)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [225]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:ANALYZE)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [229]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:POSTPROCESS)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [233]
                        )
                      ]
                    )
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:SERVE)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [237]
                        )
                      ]
                    )
                  ]
                  spids: [219 222 240 -1]
                )
                (case_arm
                  pat_list: [{<--bazel-root>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:BAZEL_ROOT)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ 
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  child: (C {<realpath>} {<-s>} {(DQ ($ Id.VSub_Number '$2'))})
                                )
                              )
                            }
                          spids: [247]
                        )
                      ]
                    )
                    (C {<shift>})
                  ]
                  spids: [243 244 263 -1]
                )
                (case_arm
                  pat_list: [{<--kythe-release>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:KYTHE_RELEASE)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ 
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  child: (C {<realpath>} {<-s>} {(DQ ($ Id.VSub_Number '$2'))})
                                )
                              )
                            }
                          spids: [270]
                        )
                      ]
                    )
                    (C {<shift>})
                  ]
                  spids: [266 267 286 -1]
                )
                (case_arm
                  pat_list: [{<--graphstore>} {<-g>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:GRAPHSTORE)
                          op: assign_op.Equal
                          rhs: {(DQ ($ Id.VSub_Number '$2'))}
                          spids: [295]
                        )
                      ]
                    )
                    (C {<shift>})
                  ]
                  spids: [289 292 303 -1]
                )
                (case_arm
                  pat_list: [{<--serving_table>} {<-s>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:SERVING_TABLE)
                          op: assign_op.Equal
                          rhs: 
                            {
                              (DQ 
                                (command_sub
                                  left_token: <Id.Left_DollarParen '$('>
                                  child: (C {<realpath>} {<-s>} {(DQ ($ Id.VSub_Number '$2'))})
                                )
                              )
                            }
                          spids: [312]
                        )
                      ]
                    )
                    (C {<shift>})
                  ]
                  spids: [306 309 328 -1]
                )
                (case_arm
                  pat_list: [{<--serving_addr>} {<-l>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:SERVING_ADDR)
                          op: assign_op.Equal
                          rhs: {(DQ ($ Id.VSub_Number '$2'))}
                          spids: [337]
                        )
                      ]
                    )
                    (C {<shift>})
                  ]
                  spids: [331 334 345 -1]
                )
                (case_arm
                  pat_list: [{<--extract>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:EXTRACT)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [352]
                        )
                      ]
                    )
                  ]
                  spids: [348 349 355 -1]
                )
                (case_arm
                  pat_list: [{<--analyze>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:ANALYZE)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [362]
                        )
                      ]
                    )
                  ]
                  spids: [358 359 365 -1]
                )
                (case_arm
                  pat_list: [{<--postprocess>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:POSTPROCESS)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [372]
                        )
                      ]
                    )
                  ]
                  spids: [368 369 375 -1]
                )
                (case_arm
                  pat_list: [{<--serve>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:SERVE)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [382]
                        )
                      ]
                    )
                  ]
                  spids: [378 379 385 -1]
                )
                (case_arm
                  pat_list: [{<Id.Lit_Star '*'>}]
                  action: [
                    (command.Simple
                      words: [{<echo>} {(DQ <'ERROR: unknown argument: '> ($ Id.VSub_Number '$1'))}]
                      redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})]
                      do_fork: T
                    )
                    (command.ControlFlow
                      token: <Id.ControlFlow_Exit exit>
                      arg_word: {<1>}
                    )
                  ]
                  spids: [388 389 407 -1]
                )
              ]
            )
            (C {<shift>})
          ]
        )
    )
    (C {<cd>} {(DQ ($ Id.VSub_DollarName '$BAZEL_ROOT'))})
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (command.DBracket
                      expr: 
                        (bool_expr.LogicalNot
                          child: 
                            (bool_expr.Unary
                              op_id: Id.BoolUnary_f
                              child: {<'third_party/kythe/BUILD'>}
                            )
                        )
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (command.Simple
              words: [
                {<echo>}
                {
                  (DQ <'ERROR: '> ($ Id.VSub_DollarName '$BAZEL_ROOT') 
                    <' is not a correctly configured Bazel repository'>
                  )
                }
              ]
              redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})]
              do_fork: T
            )
            (command.Simple
              words: [
                {<echo>}
                {
                  (DQ 
                    <
'Please pass the --bazel-root flag after running setup-bazel-repo.sh on an existing Bazel repository.'
                    >
                  )
                }
              ]
              redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})]
              do_fork: T
            )
            (command.Simple
              words: [
                {<echo>}
                {(DQ <'Example: setup-bazel-repo.sh '> ($ Id.VSub_DollarName '$BAZEL_ROOT'))}
              ]
              redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})]
              do_fork: T
            )
            (command.ControlFlow token:<Id.ControlFlow_Exit exit> arg_word:{<1>})
          ]
          spids: [425 438]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (command.DBracket
                      expr: 
                        (bool_expr.Unary
                          op_id: Id.BoolUnary_n
                          child: {(DQ ($ Id.VSub_DollarName '$EXTRACT'))}
                        )
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (C {<echo>} {(DQ <'Extracting Bazel compilations...'>)})
            (C {<rm>} {<-rf>} {<'bazel-out/'> <Id.Lit_Star '*'> <'/extra_actions/third_party/kythe/'>})
            (C {<set>} {<Id.Lit_Other '+'> <e>})
            (C {<bazel>} {<build>} 
              {<--experimental_action_listener> <Id.Lit_Equals '='> <'//third_party/kythe'> 
                <Id.Lit_Colon ':'> <java_extract_kindex>
              } 
              {<--experimental_action_listener> <Id.Lit_Equals '='> <'//third_party/kythe'> 
                <Id.Lit_Colon ':'> <cxx_extract_kindex>
              } (word.BracedTree parts:[<'//src/'> (word_part.BracedTuple words:[{<main>} {<test>}]) <'/...'>])
            )
            (C {<set>} {<-e>})
          ]
          spids: [481 494]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (command.DBracket
                      expr: 
                        (bool_expr.Unary
                          op_id: Id.BoolUnary_n
                          child: {(DQ ($ Id.VSub_DollarName '$ANALYZE'))}
                        )
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (C {<echo>} {(DQ <'Analyzing compilations...'>)})
            (C {<echo>} {(DQ <'GraphStore: '> ($ Id.VSub_DollarName '$GRAPHSTORE'))})
            (C {<rm>} {<-rf>} {(DQ ($ Id.VSub_DollarName '$GRAPHSTORE'))})
            (C {<cd>} {<'/tmp'>})
            (command.Pipeline
              children: [
                (C {<find>} {<-L>} 
                  {(DQ ($ Id.VSub_DollarName '$BAZEL_ROOT')) <'/bazel-out/'> <Id.Lit_Star '*'> 
                    <'/extra_actions/third_party/kythe/java_extra_action'>
                  } {<-name>} {(SQ <'*.kindex'>)}
                )
                (C {<parallel>} {<-L1>} 
                  {(DQ ($ Id.VSub_DollarName '$KYTHE_RELEASE')) <'/indexers/java_indexer.jar'>}
                )
                (C {(DQ ($ Id.VSub_DollarName '$KYTHE_RELEASE')) <'/tools/dedup_stream'>})
                (C {(DQ ($ Id.VSub_DollarName '$KYTHE_RELEASE')) <'/tools/write_entries'>} 
                  {<--graphstore>} {(DQ ($ Id.VSub_DollarName '$GRAPHSTORE'))}
                )
              ]
              negated: F
            )
            (C {<cd>} {(DQ ($ Id.VSub_DollarName '$ROOT'))})
          ]
          spids: [557 570]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (command.DBracket
                      expr: 
                        (bool_expr.Unary
                          op_id: Id.BoolUnary_n
                          child: {(DQ ($ Id.VSub_DollarName '$POSTPROCESS'))}
                        )
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (C {<echo>} {(DQ <'Post-processing GraphStore...'>)})
            (C {<echo>} {(DQ <'Serving table: '> ($ Id.VSub_DollarName '$SERVING_TABLE'))})
            (C {<rm>} {<-rf>} {(DQ ($ Id.VSub_DollarName '$SERVING_TABLE'))})
            (C {(DQ ($ Id.VSub_DollarName '$KYTHE_RELEASE')) <'/tools/write_tables'>} {<--graphstore>} 
              {(DQ ($ Id.VSub_DollarName '$GRAPHSTORE'))} {<--out>} {(DQ ($ Id.VSub_DollarName '$SERVING_TABLE'))}
            )
          ]
          spids: [668 681]
        )
      ]
    )
    (command.If
      arms: [
        (if_arm
          cond: 
            (condition.Shell
              commands: [
                (command.Sentence
                  child: 
                    (command.DBracket
                      expr: 
                        (bool_expr.Unary
                          op_id: Id.BoolUnary_n
                          child: {(DQ ($ Id.VSub_DollarName '$SERVE'))}
                        )
                    )
                  terminator: <Id.Op_Semi _>
                )
              ]
            )
          action: [
            (C {<echo>} {(DQ <'Launching Kythe server'>)})
            (C {<echo>} {(DQ <'Address: http://'> ($ Id.VSub_DollarName '$SERVING_ADDR'))})
            (C {(DQ ($ Id.VSub_DollarName '$KYTHE_RELEASE')) <'/tools/http_server'>} {<--listen>} 
              {(DQ ($ Id.VSub_DollarName '$SERVING_ADDR'))} {<--public_resources>} {(DQ ($ Id.VSub_DollarName '$KYTHE_RELEASE')) <'/web/ui'>} {<--serving_table>} 
              {(DQ ($ Id.VSub_DollarName '$SERVING_TABLE'))}
            )
          ]
          spids: [730 743]
        )
      ]
    )
  ]
)