Module: L43Rmap::Cli::Help

Included in:
L43Rmap::Cli
Defined in:
lib/l43_rmap/cli/help.rb

Instance Method Summary collapse

Instance Method Details

#helpObject



6
7
8
9
# File 'lib/l43_rmap/cli/help.rb', line 6

def help
  parser.help
  :helped
end

#help_namedObject



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
# File 'lib/l43_rmap/cli/help.rb', line 11

def help_named
  same = [:dim, " (is the same for all output lines)"] 
  variable = [:dim, " (might not be the same for all output lines)"]
  putcol
  putcol(:bold, :blue, "named fields", :white, " are the following:")
  putcol
  putcol(:bold, :cyan, 'Counters')
  putcol(2, :bold, :blue, "%n", :reset, " => line count of input, starting with ", :bold, :blue, "1")
  putcol
  putcol(:bold, :cyan, 'Timestamps')
  putcol(2, :bold, :blue, "%m", :reset, " => timestamp in milliseconds, base 36, from the time the pattern is compiled", same)
  putcol(2, :bold, :blue, "%t", :reset, " => timestamp in milliseconds, base 10, from the time the pattern is compiled", same)
  putcol(2, :bold, :blue, "%x", :reset, " => timestamp in milliseconds, base 16, from the time the pattern is compiled", same)
  putcol(2, :bold, :blue, "%ms", :reset, " => timestamp in seconds, base 36, from the time the pattern is compiled", same)
  putcol(2, :bold, :blue, "%ts", :reset, " => timestamp in seconds, base 10, from the time the pattern is compiled", same)
  putcol(2, :bold, :blue, "%xs", :reset, " => timestamp in seconds, base 16, from the time the pattern is compiled", same)

  putcol(2, :bold, :blue, "%M", :reset, " => timestamp in milliseconds, base 36, from the time the line is processed", variable)
  putcol(2, :bold, :blue, "%T", :reset, " => timestamp in milliseconds, base 10, from the time the line is processed", variable)
  putcol(2, :bold, :blue, "%X", :reset, " => timestamp in milliseconds, base 16, from the time the line is processed", variable)
  putcol(2, :bold, :blue, "%Ms", :reset, " => timestamp in seconds, base 36, from the time the line is processed", variable)
  putcol(2, :bold, :blue, "%Ts", :reset, " => timestamp in seconds, base 10, from the time the line is processed", variable)
  putcol(2, :bold, :blue, "%Xs", :reset, " => timestamp in seconds, base 16, from the time the line is processed", variable)

  putcol
  putcol(:bold, :cyan, 'Randomness')
  putcol(named("%rd"), " => random number base 10, 4 digits (padded with 0)", same)
  putcol(named("%rx"), " => random number base 16, 8 characters (padded with 0)", same)
  putcol(named("%Rd"), " => random number base 10, 4 digits (padded with 0)", variable)
  putcol(named("%Rx"), " => random number base 16, 8 characters (padded with 0)", variable)
  :helped
end

#help_patternObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/l43_rmap/cli/help.rb', line 44

def help_pattern
  putcol
  putcol(:bold, :blue, "pattern", :white, " is a sequence of ", :blue, "chunks")
  putcol
  putcol(2, "each ", :bold, :blue, "chunk", :reset, " is one of the following:")
  putcol(4, :bold, :blue, "field ", :reset, "of format ", :magenta, "%", :reset, " or ", :magenta, "%<integer>", :reset, :magenta, " %", :reset, " is the same as ", :magenta, "%0")
  putcol(6, "fields are the input line split by whitespace indexed by the value of ", :magenta, "<integer>")
  putcol(6, "where ", :magenta, "0 ", :reset, "is the whole line",
         :magenta, " n > 0", :reset, " the ", :magenta, "n", :reset, "-th field and ", :magenta, "n < 0", :reset, " the ", :magenta, "n", :reset, "-th field with fields reversed")

  putcol
  putcol(4, :bold, :blue, "named field ", :reset, "of format ", :magenta, "%<name>")
  putcol(6, "list all named fields by running ", :green, "rmap :help_named")

  putcol
  putcol(4, :bold, :blue, "s-expressions ", :reset, "of format ", :magenta, "(<list of chunks>)")
  putcol(6, "list all inner chunks by running ", :green, "rmap :help_sexp")
  :helped
end

#help_predefinedObject



64
65
66
67
68
69
70
71
# File 'lib/l43_rmap/cli/help.rb', line 64

def help_predefined
  putcol
  putcol(:bold, :blue, "predefined patterns", :white, " are the following:")
  putcol
  putcol(4, :bold, :magenta, "mv_to_ms", :white, " same as ", :bold, :blue, "mv %  %m-(lpad %n 0 4).(ext)")
  putcol(4, :bold, :magenta, "mv_to_mse", :white, " same as ", :bold, :blue, "mv (se) %m-(lpad %n 0 4).(ext)")
  :helped
end

#help_sexpObject



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/l43_rmap/cli/help.rb', line 73

def help_sexp
  putcol
  putcol(:bold, :blue, "s-expressions", :white, " are sequences of ", :blue, "inner chunks",
         :white, " inside a pair of ", :dim, "paranthesis", :reset, :bold, :white, " seperated by ", :dim, "whitespace")
  putcol
  putcol(2, "the first inner chunk, called ", :bold, :green, "head", :reset, " must refer to a function")
  putcol
  putcol(2, :bold, "Defined functions ", :reset, "(falls back to named fields)")
  putcol(sexp("ext", "filename:=%"), " ==> extension of ", arg("filename"))
  putcol(sexp("lpad", "subject", "filler", "len"), " ==> left pad ", arg("subject"), " with ", arg("filler"), " to length ", arg("len"))
  putcol(sexp("se", "filename:=%"), " ==> shell escape ", arg("filename"))
  :helped
end