File: README

package info (click to toggle)
golang-github-kisom-goutils 0.0~git20161101.0.858c9cb-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 396 kB
  • sloc: makefile: 6
file content (41 lines) | stat: -rw-r--r-- 941 bytes parent folder | download | duplicates (4)
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
fragment

This is a program to print a fragment of a file. It takes a filename,
a starting line (lines are numbered starting at 1) and an optional
end line or offset. It has one flag, `-nl`, which causes line numbers
not to be printed.

For example, compare the output to `nl -ba fragment.go`:

$ fragment fragment.go 23 +6
23: func main() {
24:     flag.Parse()
25: 
26:     if flag.NArg() < 2 || flag.NArg() > 3 {
27:             usage()
28:             os.Exit(1)
29:     }

$ fragment fragment.go 25 30
25: 
26:     if flag.NArg() < 2 || flag.NArg() > 3 {
27:             usage()
28:             os.Exit(1)
29:     }
30: 

$ fragment fragment.go 80
80
80:             if n > end {
81:                     return true
82:             }
83:             return false
84:     }
85: 
86:     fmt.Println(start)
87:     fmtStr += "\n"
88:     for i := start; !endFunc(i); i++ {
89:             fmt.Printf(fmtStr, i, lines[i])
90:     }
91: }