howl.io.process_output

parse(output, opts = {})

parses out line numbers and messages

assert.same {
  { line_nr: 2, message: 'foo' }
}, parse "2: foo"

opts.keep_whitespace keeps indentation for messages

assert.same {
  { line_nr: 2, message: '  foo' }
}, parse "2:  foo", keep_whitespace: true

parses out relevant tokens

assert.same {
  {
    line_nr: 3,
    message: "unused: `foo`, 'bar', ‘zed’",
    tokens: {'foo', 'bar', 'zed'}
  }
}, parse "3: unused: `foo`, 'bar', ‘zed’"

parses out columns where available

assert.same {
  { line_nr: 2, column: 12, message: 'foo' }
}, parse "2:12: foo"

(when opts.max_message_length is specified)

shortens the messages as neccessary

assert.same {
{ line_nr: 1, message: '123åäö..' }
      }, parse "1: 123åäö789", max_message_length: 8

(file references)

parses out and resolves file references according to the directory option

with_tmpdir (dir) ->
  assert.same {
    { file: dir\join('zed.moon'), path: 'zed.moon', line_nr: 3, message: 'msg' }
  }, parse "zed.moon:3: msg", directory: dir

defaults to the current working directory if the directory option is missing

glib = require 'ljglibs.glib'
cwd = File glib.get_current_dir!
assert.same {
  { file: cwd\join('zed.moon'), path: 'zed.moon', line_nr: 3, message: 'msg' }
}, parse "zed.moon:3: msg"

leaves absolute paths alone

assert.same {
  {
    file: File('/tmp/zed.moon'),
    path: '/tmp/zed.moon',
    line_nr: 3,
    message: 'msg'
  }
}, parse "/tmp/zed.moon:3: msg"

leaves "-" paths alone

assert.same {
  { path: '-', line_nr: 3, message: 'msg' }
}, parse "-:3: msg"

(formats)

handles sparse line and column information

assert.same {
  {line_nr: 3, column: 2, message: 'foo'}
}, parse "3:2:foo"

handles files ending with a number

exp = {
  {
    file: File('foo.yml.j2'),
    path: 'foo.yml.j2',
    line_nr: 10,
    column: 12,
    message: 'foo'
  }
}
assert.same exp, parse "foo.yml.j2:10:12:  foo"

handles files ending with a number when keeping keep_whitespace

exp = {
  {
    file: File('foo.yml.j2'),
    path: 'foo.yml.j2',
    line_nr: 10,
    column: 12,
    message: '  foo'
  }
}
assert.same exp, parse("foo.yml.j2:10:12:  foo", {
    keep_whitespace: true
})