chec / cli

A command line interface for using the Chec API
https://chec.io
BSD 3-Clause "New" or "Revised" License
9 stars 7 forks source link

Gracefully handle running commands while not logged in #12

Closed robbieaverill closed 4 years ago

robbieaverill commented 4 years ago

If I run the logs command before I've logged in, I get this error:

Error: Could not locate required credentials to subscribe to a log feed
    at LogFeed.getConfiguration (~/dev/chec/chec-cli/src/helpers/log-feed.js:14:13)
    at LogFeed.getChannel (~/dev/chec/chec-cli/src/helpers/log-feed.js:27:33)
    at LogFeed.onLog (~/dev/chec/chec-cli/src/helpers/log-feed.js:22:10)
    at LogsCommand.registerLogFeed (~/dev/chec/chec-cli/src/commands/logs.js:101:10)
    at LogsCommand.run (~/dev/chec/chec-cli/src/commands/logs.js:53:10)
    at LogsCommand._run (~/dev/chec/chec-cli/node_modules/@oclif/command/lib/command.js:44:31)

We could use a hook to ensure that you're logged in before running various commands, and show a friendly message like "You aren't logged in yet, run chec-cli login then try again"

robbieaverill commented 4 years ago

PR at #16