Skip to content

Commit

Permalink
Merge pull request #72 from kuzzleio/feat/es-indices
Browse files Browse the repository at this point in the history
Move ES indices related commands to es:indices namespace
  • Loading branch information
xbill82 authored Oct 26, 2020
2 parents 70b03eb + 083946d commit d3b0bc7
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 23 deletions.
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"vetur.format.defaultFormatter.ts": "prettier",
"vetur.format.defaultFormatter.js": "prettier-eslint",
"vetur.format.enable": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"typescript.tsdk": "node_modules/typescript/lib"
"editor.defaultFormatter": "vscode.typescript-language-features",
"typescript.tsdk": "node_modules/typescript/lib",
"[feature]": {
"editor.defaultFormatter": "alexkrechik.cucumberautocomplete"
}
}
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ Then any argument will be passed as-is to the `sdk:query` method.
* [`kourou collection:import PATH`](#kourou-collectionimport-path)
* [`kourou config:diff FIRST SECOND`](#kourou-configdiff-first-second)
* [`kourou document:search INDEX COLLECTION [QUERY]`](#kourou-documentsearch-index-collection-query)
* [`kourou es:get INDEX ID`](#kourou-esget-index-id)
* [`kourou es:insert INDEX`](#kourou-esinsert-index)
* [`kourou es:list-index`](#kourou-eslist-index)
* [`kourou es:indices:get INDEX ID`](#kourou-esindicesget-index-id)
* [`kourou es:indices:insert INDEX`](#kourou-esindicesinsert-index)
* [`kourou es:indices:cat`](#kourou-esindicescat)
* [`kourou file:decrypt FILE`](#kourou-filedecrypt-file)
* [`kourou file:encrypt FILE`](#kourou-fileencrypt-file)
* [`kourou file:test FILE`](#kourou-filetest-file)
Expand Down Expand Up @@ -453,13 +453,13 @@ EXAMPLES

_See code: [src/commands/document/search.ts](src/commands/document/search.ts)_

## `kourou es:get INDEX ID`
## `kourou es:indices:get INDEX ID`

Gets a document from ES

```
USAGE
$ kourou es:get INDEX ID
$ kourou es:indices:get INDEX ID
ARGUMENTS
INDEX ES Index name
Expand All @@ -471,15 +471,15 @@ OPTIONS
--help show CLI help
```

_See code: [src/commands/es/get.ts](src/commands/es/get.ts)_
_See code: [src/commands/es/indices/get.ts](src/commands/es/indices/get.ts)_

## `kourou es:insert INDEX`
## `kourou es:indices:insert INDEX`

Inserts a document directly into ES (will replace if exists)

```
USAGE
$ kourou es:insert INDEX
$ kourou es:indices:insert INDEX
ARGUMENTS
INDEX ES Index name
Expand All @@ -492,15 +492,15 @@ OPTIONS
--id=id Document ID
```

_See code: [src/commands/es/insert.ts](src/commands/es/insert.ts)_
_See code: [src/commands/es/indices/insert.ts](src/commands/es/indices/insert.ts)_

## `kourou es:list-index`
## `kourou es:indices:cat`

Lists available ES indexes

```
USAGE
$ kourou es:list-index
$ kourou es:indices:cat
OPTIONS
-g, --grep=grep Match output with pattern
Expand All @@ -509,7 +509,7 @@ OPTIONS
--help show CLI help
```

_See code: [src/commands/es/list-index.ts](src/commands/es/list-index.ts)_
_See code: [src/commands/es/indices/cat.ts](src/commands/es/indices/cat.ts)_

## `kourou file:decrypt FILE`

Expand Down
18 changes: 15 additions & 3 deletions features/Elasticsearch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@ Feature: Elasticsearch commands
And I create the following document:
| _id | "chuon-chuon-kim" |
| body | {} |
When I run the command "es:get" with args:
When I run the command "es:indices:get" with args:
| "&nyc-open-data.yellow-taxi" |
| "chuon-chuon-kim" |
Then I should match stdout with "chuon-chuon-kim"

@mappings
Scenario: List ES indexes
Scenario: Cat ES indexes
Given a collection "nyc-open-data":"green-taxi"
When I run the command "es:list-index" with flags:
When I run the command "es:indices:cat" with flags:
| --grep | "nyc-open-data" |
Then I should match stdout with "yellow-taxi"
And I should match stdout with "green-taxi"

@mappings
Scenario: Insert ES document
Given a collection "nyc-open-data":"green-taxi"
When I run the command "es:indices:insert" with:
| arg | &nyc-open-data.yellow-taxi | |
| flag | --id | kindred |
| flag | --body | {} |
When I run the command "es:indices:get" with args:
| "&nyc-open-data.yellow-taxi" |
| "kindred" |
Then I should match stdout with "kindred"
1 change: 1 addition & 0 deletions features/step_definitions/cli-steps.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs')

const _ = require('lodash')
const should = require('should')
const { Then } = require('cucumber')

// this need to build the lib with "npm run build" first
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"kuzzle-sdk": "^7.4.0",
"kuzzle-vault": "^2.0.0",
"listr": "^0.14.3",
"lodash": "^4.17.20",
"ndjson": "^1.5.0",
"node-emoji": "^1.10.0",
"strip-json-comments": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { flags } from '@oclif/command'
import { Client } from '@elastic/elasticsearch'

import { Kommand } from '../../common'
import { Kommand } from '../../../common'

export default class EsListIndex extends Kommand {
static initSdk = false
Expand Down
2 changes: 1 addition & 1 deletion src/commands/es/get.ts → src/commands/es/indices/get.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { flags } from '@oclif/command'
import { Client } from '@elastic/elasticsearch'

import { Kommand } from '../../common'
import { Kommand } from '../../../common'

export default class EsGet extends Kommand {
static initSdk = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { flags } from '@oclif/command'
import { Client } from '@elastic/elasticsearch'

import { Kommand } from '../../common'
import { Kommand } from '../../../common'

export default class EsInsert extends Kommand {
static initSdk = false
Expand Down

0 comments on commit d3b0bc7

Please sign in to comment.