oscope-dev / scope

Scoping user machines
https://oscope-dev.github.io/scope/
BSD 3-Clause "New" or "Revised" License
6 stars 3 forks source link

Add `scope analyze command` support #131

Closed noizwaves closed 4 months ago

noizwaves commented 4 months ago

Problem

When using scope analyze logs to detect known errors against command failures in a terminal, some commands will print errors to STDERR, which are missed when using a simple pipe (i.e. failing-command | scope analyze logs).

Solution

Implement a new command that can run commands directly, thereby having access to both output streams for error detection.

❯ scope analyze command --help
Runs a command and detects errors in the output

Usage: scope analyze command [OPTIONS] -- <COMMAND>...

Arguments:
  <COMMAND>...
          The command to run

...

Example

❯ scope -C scope/tests/test-cases/known-errors analyze command -- bin/error-stderr.sh
analyzing:  foo
analyzing:  bar
analyzing:  error
 WARN Known error 'error-exists' found on line 2
 INFO   ==> fix the error and try again
 INFO All known errors detected, ignoring rest of output.