Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 928b0c4

Browse files
Merge pull request #15 from MrRacoon/feature/cli
add bin/bokor for cli interface
2 parents 00e32d0 + 6aa4c3f commit 928b0c4

File tree

4 files changed

+478
-1
lines changed

4 files changed

+478
-1
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Bokor was developed and is in use at Nike since early 2016. There, it is used t
1919
- [Static Resources](#static-resources)
2020
- [Admin Server](#admin-server)
2121
- [Port](#port)
22+
- [Command Line](#command-line)
2223
- [Data Fixtures](#data-fixtures)
2324
- [Data Bins](#data-bins)
2425
- [Fixture Filenames](#fixture-filenames)
@@ -130,6 +131,23 @@ $ node server.js
130131
bokor server rolled lucky 7777
131132
```
132133

134+
### Command Line
135+
Bokor can be run through the command line using the `bokor` command.
136+
137+
```
138+
npm i -g bokor
139+
140+
$ bokor --help ⬡ 8.9.1 [±feature/cli ●●]
141+
Usage:
142+
node bokor [OPTION]
143+
144+
Options:
145+
-p, --port port of the bokor server [7777]
146+
-f, --filters file exporting filters.properties
147+
-s, --servers file exporting servers.properties
148+
-d, --datetimes file exporting datetimes.properties
149+
-h, --help display this help
150+
```
133151

134152
### Advanced Configuration
135153

bin/bokor

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env node
2+
const getOpt = require('node-getopt');
3+
const bokor = require('../index.js');
4+
const path = require('path');
5+
6+
const cli = getOpt.create([
7+
['p', 'port=NUM', 'port of the bokor server [7777]'],
8+
['f', 'filters=PATH', 'file exporting filters.properties'],
9+
['s', 'servers=PATH', 'file exporting servers.properties'],
10+
['d', 'datetimes=PATH', 'file exporting datetimes.properties'],
11+
]).bindHelp()
12+
.parseSystem();
13+
14+
const options = cli.options;
15+
const cwd = process.cwd();
16+
17+
const serversPath = path.resolve(cwd, options.servers || 'servers.properties');
18+
const filtersPath = path.resolve(cwd, options.filters || 'filters.properties');
19+
20+
options.servers = require(serversPath);
21+
options.filters = require(filtersPath);
22+
23+
bokor.start(options);
24+

0 commit comments

Comments
 (0)