Skip to content

Commit

Permalink
Allow opType to be passed to cli (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
johan-liljegren-visma authored Oct 15, 2024
1 parent 481243a commit 89f4f6a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ npm install pino-elasticsearch -g
-c | --cloud Id of the elastic cloud node to connect to
-r | --read-config the name of config file
--rejectUnauthorized Reject any connection which is not authorized with the list of supplied CAs; default: true
--opType the op_type to use (create, index)
"create" is required when using datastreams
```

### Usage as module
Expand Down
3 changes: 2 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ function startCli (flags) {
'api-key',
'cloud',
'es-version',
'rejectUnauthorized'
'rejectUnauthorized',
'opType'
]

if (flags['read-config']) {
Expand Down
20 changes: 20 additions & 0 deletions test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,23 @@ test('CLI: if arg.read-config is set, should read the config file and passed the
'read-config': 'test/exampleConfig.js'
})
})

test('CLI: arg opType should be passed to client constructor', async (t) => {
const cli = proxyquire('../cli.js', {
pump: () => { },
'./lib.js': (opts) => {
t.same(opts, {
node: 'https://custom-node-url:9999',
opType: 'create'
})
return {
on: () => { }
}
}
})

cli({
node: 'https://custom-node-url:9999',
opType: 'create'
})
})
4 changes: 3 additions & 1 deletion usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@
(can only be used in tandem with the 'username' flag)
-k | --api-key Api key for authentication instead of username/password combination
-c | --cloud Id of the elastic cloud node to connect to
-r | --read-config the config file to read
-r | --read-config the config file to read
--rejectUnauthorized Reject any connection which is not authorized with the list of supplied CAs; default: true
--opType the op_type to use (create, index)
"create" is required when using datastreams

0 comments on commit 89f4f6a

Please sign in to comment.