Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #23 from vtatai/fixing-docs
Browse files Browse the repository at this point in the history
Fixing docs
  • Loading branch information
vtatai authored Jul 31, 2020
2 parents fc74ff1 + 3577691 commit 32579bf
Showing 1 changed file with 52 additions and 25 deletions.
77 changes: 52 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,42 @@ ThriftCLI is a CLI tool for executing RPC's via the Thrift protocol.

## Installation

First, navigate to the project directory (contains setup.py):
The easiest way is to use pip:

Next, install the thrift compiler from homebrew: (this only needs to be done once)
```
pip install thriftcli
```

Another option is to manually build and compile. First, install the thrift compiler from homebrew: (this only needs to be done once)
```
brew install thrift
```

There are two ways of invoking this tool:

You can build and install it to */usr/local/bin/thriftcli*

```
python setup.py install
```

and you can run it like this: (assuming /usr/local/bin is on your PATH)
```
thriftcli server_address endpoint_name thrift_file_path [options]
```

Alternatively, you can build and start it all at once without installing: (convenient for dev)

```
python -m thriftcli server_address endpoint_name thrift_file_path [options]
```

As a convenience you can define an environment variable THRIFT_CLI_PATH. This colon delimited list of directories will be used to find thrift files and their dependencies.

Take the following command

```
thriftcli localhost:9332 MakeTestCall ~/thrift/test/test.thrift -I ~/thrift/dependencies
```

If you had run the following before

```
export THRIFT_CLI_PATH="~/thrift/test:~/thrift/dependencies"
```

this command becomes
## Running

All options for executing thriftcli can be accessed by doing:
```
thriftcli localhost:9332 MakeTestCall test.thrift
thriftcli --help
```

This variable is most useful for endpoints you call fairly often

Arguments:
This is the list of most common arguments:
- **server_address** URL to send the request to. This server should listen for and implement the requested endpoint.
- **endpoint_name** Service name and function name representing the request to send to the server.
- **thrift_file_path** Path to the thrift file containing the endpoint\'s declaration.
Expand All @@ -77,8 +65,39 @@ Options:
Finagle client id to send request with
- **-v --verbose** Provide detailed logging

## Examples
#### Includes

As a convenience you can define an environment variable THRIFT_CLI_PATH. This colon delimited list of directories will be used to find thrift files and their dependencies.

Take the following command

```
thriftcli localhost:9332 MakeTestCall ~/thrift/test/test.thrift -I ~/thrift/dependencies
```

If you had run the following before

```
export THRIFT_CLI_PATH="~/thrift/test:~/thrift/dependencies"
```

this command becomes

```
thriftcli localhost:9332 MakeTestCall test.thrift
```

This variable is most useful for endpoints you call fairly often.

#### Proxy

If you need to access a server behind a proxy, the `--proxy` option allows you to do so:

```
thriftcli server:port Hello.echo Hello.thrift -b '{"name": "World"}' -j --proxy prod-proxy-us-central1.gcp.fitbit.com:3128
```

## Examples
```
thriftcli localhost:9090 Calculator.ping ./Calculator.thrift
thriftcli localhost:9090 Calculator.add ./Calculator.thrift --body add_request_body.json
Expand Down Expand Up @@ -123,9 +142,17 @@ If you provide ThriftCLI with a thrift file that uses a Python keyword, or has a

A full list of Python keywords can be found at https://docs.python.org/2/reference/lexical_analysis.html#keywords.

#### Unions

Unions are not supported right now.

#### Python 2.7

Python 3 is not supported. Due to the dependency we have on Twitter thrift libraries (Python 2 only) upgrading is not straightforward.

## License

Copyright 2017, Fitbit, Inc.
Copyright 2020, Fitbit, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down

0 comments on commit 32579bf

Please sign in to comment.