github.com/pvitto98/fabric@v2.1.1+incompatible/scripts/generateHelpDocs.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright IBM Corp. All Rights Reserved.
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  #
     7  PATH=build/bin/:${PATH}
     8  
     9  # Takes in 4 arguments
    10  # 1. Output doc file
    11  # 2. Preamble Text File
    12  # 3. Postscript File
    13  # 4. Array of commands
    14  generateHelpText(){
    15      local DOC="$1"
    16      local preamble="$2"
    17      local postscript="$3"
    18      # Shift three times to get to array
    19      shift
    20      shift
    21      shift
    22  
    23      cat "$preamble" > "$DOC"
    24  
    25      local commands=("$@")
    26      for x in "${commands[@]}" ; do
    27  
    28      cat <<EOF >> "$DOC"
    29  
    30  ## $x
    31  \`\`\`
    32  $($x --help 2>&1)
    33  \`\`\`
    34  
    35  EOF
    36      done
    37      cat "$postscript" >> "$DOC"
    38  }
    39  
    40  commands=("peer version")
    41  generateHelpText \
    42          docs/source/commands/peerversion.md \
    43          docs/wrappers/peer_version_preamble.md \
    44          docs/wrappers/license_postscript.md \
    45          "${commands[@]}"
    46  
    47  commands=("peer chaincode install" "peer chaincode instantiate" "peer chaincode invoke" "peer chaincode list" "peer chaincode package" "peer chaincode query" "peer chaincode signpackage" "peer chaincode upgrade")
    48  generateHelpText \
    49          docs/source/commands/peerchaincode.md \
    50          docs/wrappers/peer_chaincode_preamble.md \
    51          docs/wrappers/peer_chaincode_postscript.md \
    52          "${commands[@]}"
    53  
    54  commands=("peer lifecycle" "peer lifecycle chaincode" "peer lifecycle chaincode package" "peer lifecycle chaincode install" "peer lifecycle chaincode queryinstalled" "peer lifecycle chaincode getinstalledpackage" "peer lifecycle chaincode approveformyorg" "peer lifecycle chaincode checkcommitreadiness" "peer lifecycle chaincode commit" "peer lifecycle chaincode querycommitted")
    55  generateHelpText \
    56          docs/source/commands/peerlifecycle.md \
    57          docs/wrappers/peer_lifecycle_chaincode_preamble.md \
    58          docs/wrappers/peer_lifecycle_chaincode_postscript.md \
    59          "${commands[@]}"
    60  
    61  commands=("peer channel" "peer channel create" "peer channel fetch" "peer channel getinfo" "peer channel join" "peer channel list" "peer channel signconfigtx" "peer channel update")
    62  generateHelpText \
    63          docs/source/commands/peerchannel.md \
    64          docs/wrappers/peer_channel_preamble.md \
    65          docs/wrappers/peer_channel_postscript.md \
    66          "${commands[@]}"
    67  
    68  commands=("peer node start" "peer node reset" "peer node rollback")
    69  generateHelpText \
    70          docs/source/commands/peernode.md \
    71          docs/wrappers/peer_node_preamble.md \
    72          docs/wrappers/peer_node_postscript.md \
    73          "${commands[@]}"
    74  
    75  commands=("configtxgen")
    76  generateHelpText \
    77          docs/source/commands/configtxgen.md \
    78          docs/wrappers/configtxgen_preamble.md \
    79          docs/wrappers/configtxgen_postscript.md \
    80          "${commands[@]}"
    81  
    82  commands=("cryptogen help" "cryptogen generate" "cryptogen showtemplate" "cryptogen extend" "cryptogen version")
    83  generateHelpText \
    84          docs/source/commands/cryptogen.md \
    85          docs/wrappers/cryptogen_preamble.md \
    86          docs/wrappers/cryptogen_postscript.md \
    87          "${commands[@]}"
    88  
    89  commands=("configtxlator start" "configtxlator proto_encode" "configtxlator proto_decode" "configtxlator compute_update" "configtxlator version")
    90  generateHelpText \
    91          docs/source/commands/configtxlator.md \
    92          docs/wrappers/configtxlator_preamble.md \
    93          docs/wrappers/configtxlator_postscript.md \
    94          "${commands[@]}"
    95  
    96  exit