diff --git a/README.md b/README.md index aca61eb..5c3417a 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,15 @@ The only configuration you need to provide is a mapping, which maps a folder on host = "https://example.org" ``` +same example saved as default.json +```json +{ "mappings": { + "example": { + "host": "https://example.org" + } + } +} +``` This is the minimal required configuration. It will map `http://localhost:/example/*` to `https://example.org/*`. @@ -174,6 +183,20 @@ Date: Thu, 11 Feb 2016 17:24:10 GMT {"status":"ok"} ``` + +## CLI + +| param | description | +|------------------|--------------------------------------------------------------------------------------| +| `root` or `(r)` | This is the folder where mock files will be saved | +| `config` or `(c)`| This is the folder where config files are located | +| `name` or `(n)` | This is config file name | + +And example: +``` +npm run start --config "./config_dir" --name "amp_config_file_name" --root "./config_dir/mocks" +``` + ## Advanced There are some more advanced configuration options available. For example, AMP uses [node-config][nc] to manage its config files, so there are options for providing different config files per environment. diff --git a/src/argv.js b/src/argv.js new file mode 100644 index 0000000..ea14eee --- /dev/null +++ b/src/argv.js @@ -0,0 +1,17 @@ +/* globals process */ +import minimist from 'minimist'; + +const argv = minimist(process.argv.slice(2), {alias: { + root: ['r', 'data'], + config: ['c'], + name: ['n'] +}}); + +if (argv.config) { + process.env.NODE_CONFIG_DIR = argv.config; +} +if (argv.name) { + process.env.NODE_ENV = argv.name; +} + +export default argv; diff --git a/src/cli.js b/src/cli.js index 40776d4..1479f9a 100644 --- a/src/cli.js +++ b/src/cli.js @@ -1,11 +1,9 @@ /* globals process */ -import minimist from 'minimist'; +import argv from './argv'; import cacher from './cacher'; import server from './serve'; import config from 'config'; -const argv = minimist(process.argv.slice(2), {alias: {root: ['r', 'data']}}); - if (argv.root) { cacher.root = argv.root; }