Skip to content

Warns errors and warns with sound.

License

Notifications You must be signed in to change notification settings

Bakudankun/ErrorWarner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

にほんご

ErrorWarner

ErrorWarner plays sound when errors or warnings are found while build process.

DEMO

Installation

Platforms

  • Windows
  • macOS
  • Linux
  • other OSs which Oto supports (hopefully)

Build

Install Go and run following command.

go get -v github.com/Bakudankun/ErrorWarner/errwarn

Library package may be required on Linux. See README of Oto.

Place sound files

Currently no sound data is bundled. Please prepare ones by yourself.

errwarn ""

This command line should fail, and creates ErrorWarner directory in following directory.

  • Windows: %APPDATA% (usually C:\Users\USERNAME\AppData\Roaming)
  • macOS: $HOME/Library/Application Support
  • Linux: $HOME/.config

Place sound files in it and name it error.* or warn.*. Supported formats are WAV, MP3, FLAC and Ogg Vorbis.

Usage

$ errwarn -h
Usage of errwarn:
  errwarn [OPTIONS] [--] <cmdline>
  <cmdline> | errwarn [OPTIONS]

OPTIONS
  -e <regexp>
        Use <regexp> to match errors
  -p <preset>
        Use <preset> described in config
  -s <soundset>
        Use sounds of <soundset>
  -stdout
        Read stdout of given <cmdline> instead of stderr.
  -w <regexp>
        Use <regexp> to match warnings

Pass a command line to ErrorWarner

errwarn [OPTIONS] [--] <cmdline>

errwarn executes given <cmdline> and reads its output. When a line matches the regular expressions specified with -e or -w, ErrorWarner notifies you with sound. The exit status will be the same with that of <cmdline> unless errwarn itself throws an error.

errwarn reads standard error by default. Set -stdout if <cmdline> writes logs to standard output.

Read standard input

<cmdline> | errwarn [OPTIONS]

If <cmdline> is not given as argument, errwarn reads its standard input. Note that errwarn likely to exit successfully regardless of exit status of <cmdline>. -stdout option is ignored in this form.

Presets

To reuse regular expressions, you can create presets to switch with -p option by writing config.toml file in ErrorWarner directory created above.

If a preset name matches executing command's name (extension trimmed), the preset will be selected automatically.

Example of config.toml:

# preset with empty name is used to set default values
[preset.""]
stdout = true               # read stdout instead of stderr
errorFormat = '(?i:error)'  # regexp to mach errors
warningFormat = '(?i:warn)' # regexp to mach warnings
soundset = 'foo'            # soundset

# call this preset like `errwarn -p gcc make`
[preset.gcc]
stdout = false
errorFormat = '^\S+:\d+:\d+: error: '
warningFormat = '^\S+:\d+:\d+: warning: '
soundset = 'bar'

# automatically selected when you execute `errwarn go build`
[preset.go]
stdout = false
errorFormat = '^.*: '
warningFormat = '' # disabled if empty

Soundsets

You can create soundsets by creating soundsets/* directory under the ErrorWarner directory.

ErrorWarner
|-- config.toml
|-- error.wav
|-- warn.wav
|-- ...
|
+-- soundsets
    +-- foo
    |   |-- error.ogg
    |   |-- warn.ogg
    |   |-- ...
    |
    +-- bar
        |-- error.flac
        |-- warn.flac
        |-- ...

Soundsets can be specified with -s option or soundset param in config. If none or empty name is specified, Sound files right under the ErrorWarner directory will be used.

Sounds

ErrorWarner uses sound files of following names.

  • error.*
    Played when a error is found.
  • warn.*
    Played when a warnings is found.
  • start.*
    Played on given command's starting.
  • finish.*
    Played if given command exited successfully though some errors or warnings were found. If errwarn is reading its stdin, this always be played on exit.
  • success.*
    Played if given command exited successfully with no errors or warnings. Not used if errwarn is reading its stdin.
  • fail.*
    Played if given command exited unsuccessfully. Not used if errwarn is reading its stdin.

License

MIT

Happy Erroring!!

About

Warns errors and warns with sound.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages