]> Cypherpunks.ru repositories - goredo.git/blob - usage.go
Do not use deprecated os.SEEK_*
[goredo.git] / usage.go
1 /*
2 goredo -- djb's redo implementation on pure Go
3 Copyright (C) 2020-2021 Sergey Matveev <stargrave@stargrave.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package main
19
20 import (
21         "flag"
22         "fmt"
23         "os"
24 )
25
26 const (
27         Version  = "1.3.0"
28         Warranty = `Copyright (C) 2020-2021 Sergey Matveev
29
30 This program is free software: you can redistribute it and/or modify
31 it under the terms of the GNU General Public License as published by
32 the Free Software Foundation, version 3 of the License.
33
34 This program is distributed in the hope that it will be useful,
35 but WITHOUT ANY WARRANTY; without even the implied warranty of
36 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37 GNU General Public License for more details.
38
39 You should have received a copy of the GNU General Public License
40 along with this program.  If not, see <http://www.gnu.org/licenses/>.`
41 )
42
43 func usage(cmd string) {
44         var d string
45         switch cmd {
46         case "redo":
47                 d = `Usage: redo [options] [target ...]
48
49 Forcefully and *sequentially* build specified targets.`
50         case "redo-ifchange":
51                 d = `Usage: redo-ifchange target [...]
52
53 Build specified targets in parallel, if they are changed.
54 Record them as dependencies for current target.`
55         case "redo-ifcreate":
56                 d = `Usage: redo-ifcreate target [...]
57
58 Record ifcreate dependency for current target. Unusable outside .do.`
59         case "redo-always":
60                 d = `Usage: redo-always
61
62 Always build current target. Unusable outside .do.`
63         case "redo-cleanup":
64                 d = `Usage: redo-cleanup [-dry-run] {full,log,tmp} [...]
65
66 Remove either all goredo's related temporary files, or kept stderr
67 logs, or everything (including .redo directories) related.`
68         case "redo-log":
69                 d = `Usage: redo-log target [ | tai64nlocal ]
70
71 Display kept target's stderr with TAI64N timestamped lines. Only the
72 last build is kept. You must enable stderr keeping with either -logs,
73 or REDO_LOGS=1.`
74         case "redo-dot":
75                 d = `Usage: redo-dot target [...]
76
77 Write dependency DOT graph to stdout.`
78         case "redo-stamp":
79                 d = `Usage: redo-stamp < [$3]
80
81 Record stamp dependency for current target. Unusable outside .do.
82 Stamp dependency does not play any role, as all targets are hashed
83 anyway.`
84         case "redo-whichdo":
85                 d = `Usage: redo-whichdo target
86
87 Display .do search paths for specified target. Exits successfully
88 if the last .do in output if the found existing one.`
89         case "redo-targets":
90                 d = `Usage: redo-targets
91
92 List all currently known targets.`
93         case "redo-sources":
94                 d = `Usage: redo-sources
95
96 List all currently known source files.`
97         case "redo-ood":
98                 d = `Usage: redo-ood
99
100 List all currently known out-of-date targets.`
101         default:
102                 d = `Usage: goredo -symlinks
103
104 goredo expects to be called through the symbolic link to it.
105 Available commands: redo, redo-always, redo-cleanup, redo-dot,
106 redo-ifchange, redo-ifcreate, redo-log, redo-stamp, redo-whichdo.`
107         }
108         fmt.Fprintf(os.Stderr, "%s\n\nCommon options:\n", d)
109         flag.PrintDefaults()
110         fmt.Fprintln(os.Stderr, `
111 Additional environment variables:
112   NO_COLOR -- disable messages colouring
113   REDO_NO_SYNC -- disable files/directories explicit filesystem syncing
114   REDO_TOP_DIR -- do not search for .do above that directory
115                   (it can contain .redo/top as an alternative)
116   REDO_INODE_NO_TRUST -- do not trust inode information (except for size)
117                          and always check file's hash`)
118 }