github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/docs/API/CLI.md (about)

     1  # Command-line Interface (CLI)
     2  
     3  To view the currently available CLI commands, execute the following:
     4  
     5  ```
     6      cd /opt/gopath/src/github.com/hyperledger/fabric
     7      build/bin/peer
     8  ```
     9  
    10  You will see output similar to the example below (**NOTE:** rootcommand below
    11  is hardcoded in [main.go](https://github.com/hyperledger/fabric/blob/master/main.go).
    12  Currently, the build will create a *peer* executable file).
    13  
    14  ```
    15      Usage:
    16        peer [flags]
    17        peer [command]
    18  
    19      Available Commands:
    20        version     Print fabric peer version.
    21        node        node specific commands.
    22        network     network specific commands.
    23        chaincode   chaincode specific commands.
    24        help        Help about any command
    25  
    26      Flags:
    27        -h, --help[=false]: help for peer
    28            --logging-level="": Default logging level and overrides, see core.yaml for full syntax
    29            --test.coverprofile="coverage.cov": Done
    30        -v, --version[=false]: Show current version number of fabric peer server
    31  
    32  
    33      Use "peer [command] --help" for more information about a command.
    34  
    35  ```
    36  
    37  The `peer` command supports several subcommands and flags, as shown above. To
    38  facilitate its use in scripted applications, the `peer` command always
    39  produces a non-zero return code in the event of command failure. Upon success,
    40  many of the subcommands produce a result on **stdout** as shown in the table
    41  below:
    42  
    43  Command | **stdout** result in the event of success
    44  --- | ---
    45  `version`          | String form of `peer.version` defined in [core.yaml](https://github.com/hyperledger/fabric/blob/master/peer/core.yaml)
    46  `node start`       | N/A
    47  `node status`      | String form of [StatusCode](https://github.com/hyperledger/fabric/blob/master/protos/server_admin.proto#L36)
    48  `node stop`        | String form of [StatusCode](https://github.com/hyperledger/fabric/blob/master/protos/server_admin.proto#L36)
    49  `network login`    | N/A
    50  `network list`     | The list of network connections to the peer node.
    51  `chaincode deploy` | The chaincode container name (hash) required for subsequent `chaincode invoke` and `chaincode query` commands
    52  `chaincode invoke` | The transaction ID (UUID)
    53  `chaincode query`  | By default, the query result is formatted as a printable
    54  string. Command line options support writing this value as raw bytes (-r, --raw),
    55  or formatted as the hexadecimal representation of the raw bytes (-x, --hex). If
    56  the query response is empty then nothing is output.
    57  
    58  ## Deploy a Chaincode
    59  
    60  Deploy creates the docker image for the chaincode and subsequently deploys the
    61  package to the validating peer. An example is below.
    62  
    63  ```
    64  peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'
    65  ```
    66  Or:
    67  
    68  ```
    69  peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args": ["init", "a","100", "b", "200"]}'
    70  ```
    71  
    72  The response to the chaincode deploy command will contain the chaincode
    73  identifier (hash) which will be required on subsequent `chaincode invoke`
    74  and `chaincode query` commands in order to uniquely identify the deployed
    75  chaincode.
    76  
    77  **Note:** If your GOPATH environment variable contains more than one element,
    78  the chaincode must be found in the first one or deployment will fail.