dtas.git  about / heads / tags
duct tape audio suite for *nix
blob 388f7ba0eae53ede194442fb23d667eb3916dc6e 1109 bytes (raw)
$ git show v0.16.1:bin/dtas-partstats	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
#!/usr/bin/env ruby
# Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
# frozen_string_literal: true
# TODO
# - option parsing: sox effects, stats effect options
# - support piping out to external processes
# - configurable output formatting
# - Sequel/SQLite support
require 'dtas/partstats'
infile = ARGV[0] or abort "usage: #$0 INFILE"
ps = DTAS::PartStats.new(infile)

def nproc
  require 'etc'
  Etc.nprocessors
rescue NoMethodError
  `nproc 2>/dev/null || echo 2`.to_i
end

opts = { jobs: nproc }
stats = ps.run(opts)

headers = ps.key_idx.to_a
headers = headers.sort_by! { |(n,i)| i }.map! { |(n,_)| n }
width = ps.key_width
print "    time "
puts(headers.map do |h|
  cols = width[h]
  sprintf("% #{(cols * 6)+cols-1}s", h.tr(' ','_'))
end.join(" | "))

stats.each do |row|
  trim_part = row.shift
  print "#{trim_part.hhmmss} "
  puts(row.map do |group|
    group.map do |f|
      case f
      when Float
        sprintf("% 6.2f", f)
      else
        sprintf("% 6s", f)
      end
    end.join(" ")
  end.join(" | "))
end

git clone git://80x24.org/dtas.git
git clone https://80x24.org/dtas.git