Skip to content

Commit

Permalink
feat: Issue #7: Quiet mode
Browse files Browse the repository at this point in the history
  • Loading branch information
meenahoda committed Jun 6, 2018
1 parent 8f02434 commit d1a6483
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ $ npm run cli --command=search --query=kebab --limit=12 --offset=0

To find the input flags, you can look in the run-configurations directory and find the state machine you wish to run.

#### quiet
Including 'quiet' in the command will make it run in 'quiet mode' and does not put anything onto the console

```bash
$ npm rul cli quiet --command=incidentsInProgress
```

### Build environment variables
| Environment Variable | Notes | Example |
| -------------------- | ----- | ------- |
Expand Down
11 changes: 7 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const BASE_URL = process.env.TYMLY_API_URL
const EXECUTIONS_URL = `${BASE_URL}/executions`

module.exports = async function () {
const quietMode = process.argv.includes('quiet')

const configKey = process.env.npm_config_command
if (!configKey) throw new Error(`You must specify a command`)

Expand All @@ -28,12 +30,13 @@ module.exports = async function () {
input,
config.options,
token,
config.timeout || 0
config.timeout || 0,
quietMode
)
}

function executeStateMachine (stateMachineName, input, options, token, timeout) {
console.log('Executing:\n', {stateMachineName, input, options})
function executeStateMachine (stateMachineName, input, options, token, timeout, quietMode) {
if (!quietMode) console.log('Executing:\n', {stateMachineName, input, options})

return axios.post(
EXECUTIONS_URL,
Expand All @@ -51,7 +54,7 @@ function executeStateMachine (stateMachineName, input, options, token, timeout)
process.exit(1)
}

console.log('Response:\n', response.data)
if (!quietMode) console.log('Response:\n', response.data)
})
.catch(err => {
console.error(err)
Expand Down

0 comments on commit d1a6483

Please sign in to comment.