]> Cypherpunks.ru repositories - goredo.git/blob - usage.go
28036282fe0801c72ed89f5f69427666b43f99f2
[goredo.git] / usage.go
1 /*
2 goredo -- djb's redo implementation on pure Go
3 Copyright (C) 2020-2023 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  = "2.2.0"
28         Warranty = `Copyright (C) 2020-2023 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 CmdNameRedo:
47                 d = `Usage: redo [-j X] [-k] [-s] [-x|-xx] [options] [target ...]
48
49 Forcefully and *sequentially* build specified targets.
50 If no targets specified, then use "all" one.`
51         case CmdNameRedoIfchange:
52                 d = `Usage: redo-ifchange [-j X] [-k] [-s] [-x|-xx] target [...]
53
54 Build specified targets in parallel, if they are changed.
55 Record them as dependencies for current target.`
56         case CmdNameRedoIfcreate:
57                 d = `Usage: redo-ifcreate target [...]
58
59 Record ifcreate dependency for current target. Unusable outside .do.`
60         case CmdNameRedoAlways:
61                 d = `Usage: redo-always
62
63 Always build current target. Unusable outside .do.`
64         case CmdNameRedoCleanup:
65                 d = `Usage: redo-cleanup [-n] {full,log,lock,tmp} [...]
66
67 Remove either all of goredo's related temporary files, or kept stderr
68 logs, or lock files, or everything (including .redo directories) related.`
69         case CmdNameRedoLog:
70                 d = `Usage: redo-log [-c] [-r] target [ | tai64nlocal ]
71
72 Display kept target's stderr with TAI64N timestamped lines. Only the
73 last build is kept. You must enable stderr keeping with either -logs,
74 or REDO_LOGS=1. -c option show the exact command invoked, start and
75 finish time. -r option recursively and linearly show also all deeper
76 redo calls and their logs.`
77         case CmdNameRedoDot:
78                 d = `Usage: redo-dot target [...]
79
80 Write dependency DOT graph to stdout.`
81         case CmdNameRedoStamp:
82                 d = `Usage: redo-stamp < [$3]
83
84 Record stamp dependency for current target. Unusable outside .do.
85 Stamp dependency does not play any role, as all targets are hashed
86 anyway.`
87         case CmdNameRedoWhichdo:
88                 d = `Usage: redo-whichdo target
89
90 Display .do search paths for specified target. Exits successfully
91 if the last .do in output if the found existing one.`
92         case CmdNameRedoTargets:
93                 d = `Usage: redo-targets [target ...]
94
95 List all currently known targets.`
96         case CmdNameRedoSources:
97                 d = `Usage: redo-sources [target ...]
98
99 List all currently known source files.`
100         case CmdNameRedoOOD:
101                 d = `Usage: redo-ood [target ...]
102
103 List all currently known out-of-date targets.`
104         case CmdNameRedoAffects:
105                 d = `Usage: redo-affects target [...]
106
107 List all targets that will be affected by changing the specified ones.`
108         case CmdNameRedoDep2Rec:
109                 d = `Usage: redo-dep2rec .../.redo/file.dep
110
111 Convert binary .dep file to recfile and write it to stdout.`
112         case CmdNameRedoDepFix:
113                 d = `Usage: redo-depfix
114
115 Traverse over all .redo directories beneath and recalculate each target's
116 inode and hash information, rewriting dependency files. If dependency has
117 legacy .rec format, then it will be converted to .dep one.`
118         case CmdNameRedoInode:
119                 d = `Usage: redo-inode target [...]
120
121 Just calculate inode information about each target and print in recfile format.`
122         default:
123                 d = `Usage: goredo -symlinks
124
125 goredo expects to be called through the symbolic link to it.
126 Available commands: redo, redo-affects, redo-always, redo-cleanup,
127 redo-dep2rec, redo-depfix, redo-dot, redo-ifchange, redo-ifcreate,
128 redo-inode, redo-log, redo-ood, redo-sources, redo-stamp,
129 redo-targets, redo-whichdo.`
130         }
131         fmt.Fprintf(os.Stderr, "%s\n\nCommon options:\n", d)
132         flag.PrintDefaults()
133         fmt.Fprintln(os.Stderr, `
134 Additional environment variables:
135   NO_COLOR -- disable messages colouring
136   REDO_TOP_DIR -- do not search for .do above that directory
137                   (it can contain .redo/top as an alternative)`)
138         if cmd == CmdNameRedo || cmd == CmdNameRedoIfchange {
139                 fmt.Fprintln(os.Stderr, `
140   REDO_NO_SYNC -- disable files/directories explicit filesystem syncing
141   REDO_INODE_TRUST -- {none,ctime,mtime}, either do not trust inode
142                       information at all (always check size and hash), or
143                       trust its ctime (the default one), or be satisfied
144                       with its mtime
145   REDO_MAKE -- bmake/gmake/none(default) jobserver protocol compatibility`)
146         }
147 }