Skip to content
This repository was archived by the owner on Aug 10, 2020. It is now read-only.

add global flag support for —silent, —json, —auth #13

Merged
merged 6 commits into from
Jul 23, 2019

Conversation

DavidWells
Copy link
Contributor

@DavidWells DavidWells commented Jul 18, 2019

This updates command parser to allow any command using this.parse to accept --json, --auth, & --silent flags.

Todo:

  • Update this.log to support silent
  • Add json support to commands returning data

@DavidWells
Copy link
Contributor Author

Ref netlify/cli#248

@DavidWells
Copy link
Contributor Author

Unclear on what version node ...spread args where introduced.

Might need to change the log mechanism for older node

  log(message = '', ...args) {
    if (this.argv && this.argv.includes('--silent')) {
      return
    }
    message = typeof message === 'string' ? message : inspect(message)
    process.stdout.write(format(message, ...args) + '\n')
  }

@DavidWells
Copy link
Contributor Author

Need to change auth flag here to identity https://github.com/netlify/netlify-dev-plugin/blob/master/src/commands/functions/invoke.js#L248-L253 to avoid collision

@DavidWells DavidWells removed the wip label Jul 22, 2019
@DavidWells DavidWells requested a review from RaeesBhatti July 22, 2019 21:51
@DavidWells
Copy link
Contributor Author

JSON example

image

@DavidWells
Copy link
Contributor Author

There is a chalk api proxy for --json mode

If we don't disable chalk output in JSON gets garbled like:

image

After the proxy:

image

Effectively all this.chalk.whatever.hahaha.yolo('message here') calls get noOp and simply return their value without coloring.


Alternative method https://github.com/chalk/chalk#chalklevel level 0. I tried this and it looks like the version of chalk we use doesn't support.

@DavidWells DavidWells merged commit b7689ca into master Jul 23, 2019
@DavidWells DavidWells deleted the addGlobalFlagSupport branch July 23, 2019 19:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants