Skip to content

Commit b09676a

Browse files
committed
Updating Readme to explain options better
1 parent 9695c4e commit b09676a

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

Readme.md

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ Or use it on its own:
2121
github = require('githubot')
2222
```
2323

24-
Specify a different Github API version (default is `beta`):
25-
26-
```coffeescripts
27-
module.exports = (robot) ->
28-
github = require('githubot')(robot, apiVersion: 'preview')
29-
```
24+
You can pass additional [options](#options) to the constructor if needed.
3025

3126
## Use ##
3227

@@ -90,17 +85,45 @@ This will happen with the bespoke methods as well:
9085
gh.branches "githubot", (branches) ->
9186
```
9287

93-
### Options ###
88+
## Options ##
89+
90+
### Passing options ###
91+
92+
Options may be passed to githubot in three different ways,
93+
in increasing order of precedence:
94+
95+
1. Through shell environment variables.
96+
2. Through the constructor:
97+
98+
```coffeescript
99+
github = require('githubot')(robot, apiVersion: 'preview')
100+
```
101+
3. Using `withOptions`, which lets you pass options to only some requests:
102+
103+
```coffeescript
104+
github = require('githubot')(robot)
105+
preview = github.withOptions(apiVersion: 'preview')
106+
# Uses preview API
107+
preview.get '/preview/feature', -> # ...
108+
# Uses regular API
109+
github.get '/regular/feature', -> # ...
110+
```
111+
112+
### Available options ###
94113

95-
* `HUBOT_GITHUB_TOKEN`: GitHub API token. Required to perform authenticated actions.
114+
* `token`/`process.env.HUBOT_GITHUB_TOKEN`:
115+
GitHub API token. Required to perform authenticated actions.
96116

97-
* `HUBOT_GITHUB_USER`: Default GitHub username to use if one is not given.
117+
* `defaultUser`/`process.env.HUBOT_GITHUB_USER`:
118+
Default GitHub username to use if one is not given.
98119

99-
* `HUBOT_GITHUB_API`: The base API URL. This is useful for Enterprise Github installations.
120+
* `apiRoot`/`process.env.HUBOT_GITHUB_API`:
121+
The base API URL. This is useful for Enterprise Github installations.
100122

101-
For example, `HUBOT_GITHUB_API='http://myprivate.github.int'`
123+
For example, `HUBOT_GITHUB_API='https://myprivate.github.int'`
102124

103-
* `HUBOT_CONCURRENT_REQUESTS`: Limits the allowed number of concurrent requests to the GitHub API. Defaults to 20.
125+
* `concurrentRequests`/`process.env.HUBOT_CONCURRENT_REQUESTS`:
126+
Limits the allowed number of concurrent requests to the GitHub API. Defaults to 20.
104127

105128
## Bespoke API access ##
106129

0 commit comments

Comments
 (0)