]> Cypherpunks.ru repositories - goredo.git/blob - usage.go
Download link for 2.6.2 release
[goredo.git] / usage.go
1 // goredo -- djb's redo implementation on pure Go
2 // Copyright (C) 2020-2024 Sergey Matveev <stargrave@stargrave.org>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, version 3 of the License.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 package main
17
18 import (
19         "flag"
20         "fmt"
21         "os"
22 )
23
24 const (
25         Version  = "2.6.2"
26         Warranty = `Copyright (C) 2020-2024 Sergey Matveev
27
28 This program is free software: you can redistribute it and/or modify
29 it under the terms of the GNU General Public License as published by
30 the Free Software Foundation, version 3 of the License.
31
32 This program is distributed in the hope that it will be useful,
33 but WITHOUT ANY WARRANTY; without even the implied warranty of
34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
35 GNU General Public License for more details.
36
37 You should have received a copy of the GNU General Public License
38 along with this program.  If not, see <http://www.gnu.org/licenses/>.`
39 )
40
41 func usage(cmd string) {
42         var d string
43         switch cmd {
44         case CmdNameRedo:
45                 d = `Usage: redo [-j X] [-k] [-s] [-x|-xx] [options] [target ...]
46
47 Forcefully and *sequentially* build specified targets.
48 If no targets specified, then use "all" one.`
49         case CmdNameRedoIfchange:
50                 d = `Usage: redo-ifchange [-j X] [-k] [-s] [-x|-xx] target [...]
51
52 Build specified targets in parallel, if they are changed.
53 Record them as dependencies for current target.`
54         case CmdNameRedoIfcreate:
55                 d = `Usage: redo-ifcreate target [...]
56
57 Record ifcreate dependency for current target. Unusable outside .do.`
58         case CmdNameRedoAlways:
59                 d = `Usage: redo-always
60
61 Always build current target. Unusable outside .do.`
62         case CmdNameRedoCleanup:
63                 d = `Usage: redo-cleanup [-n] {full,log,lock,tmp} [...]
64
65 Remove either all of goredo's related temporary files, or kept stderr
66 logs, or lock files, or everything (including .redo directories) related.`
67         case CmdNameRedoLog:
68                 d = `Usage: redo-log [-c] [-r] target [ | tai64nlocal ]
69
70 Display kept target's stderr with TAI64N timestamped lines. Only the
71 last build is kept. You must enable stderr keeping with either -logs,
72 or REDO_LOGS=1. -c option show the exact command invoked, start and
73 finish time. -r option recursively and linearly show also all deeper
74 redo calls and their logs.`
75         case CmdNameRedoDot:
76                 d = `Usage: redo-dot target [...]
77
78 Write dependency DOT graph to stdout.`
79         case CmdNameRedoStamp:
80                 d = `Usage: redo-stamp < [$3]
81
82 Record stamp dependency for current target. Unusable outside .do.
83 Stamp dependency does not play any role, as all targets are hashed
84 anyway.`
85         case CmdNameRedoWhichdo:
86                 d = `Usage: redo-whichdo target
87
88 Display .do search paths for specified target. Exits successfully
89 if the last .do in output if the found existing one.`
90         case CmdNameRedoTargets:
91                 d = `Usage: redo-targets [target ...]
92
93 List all currently known targets.`
94         case CmdNameRedoSources:
95                 d = `Usage: redo-sources [target ...]
96
97 List all currently known source files.`
98         case CmdNameRedoOOD:
99                 d = `Usage: redo-ood [target ...]
100
101 List all currently known out-of-date targets.`
102         case CmdNameRedoAffects:
103                 d = `Usage: redo-affects target [...]
104
105 List all targets that will be affected by changing the specified ones.`
106         case CmdNameRedoDep2Rec:
107                 d = `Usage: redo-dep2rec .../.redo/file.dep
108
109 Convert binary .dep file to recfile and write it to stdout.`
110         case CmdNameRedoDepFix:
111                 d = `Usage: redo-depfix
112
113 Traverse over all .redo directories beneath and recalculate each target's
114 inode and hash information, rewriting dependency files. If dependency has
115 legacy .rec format, then it will be converted to .dep one.`
116         case CmdNameRedoInode:
117                 d = `Usage: redo-inode target [...]
118
119 Just calculate inode information about each target and print in recfile format.`
120         default:
121                 d = `Usage: goredo -symlinks
122
123 goredo expects to be called through the symbolic link to it.
124 Available commands: redo, redo-affects, redo-always, redo-cleanup,
125 redo-dep2rec, redo-depfix, redo-dot, redo-ifchange, redo-ifcreate,
126 redo-inode, redo-log, redo-ood, redo-sources, redo-stamp,
127 redo-targets, redo-whichdo.`
128         }
129         fmt.Fprintf(os.Stderr, "%s\n\nCommon options:\n", d)
130         flag.PrintDefaults()
131         fmt.Fprintln(os.Stderr, `
132 Additional environment variables:
133   NO_COLOR -- disable messages colouring
134   REDO_TOP_DIR -- do not search for .do above that directory
135                   (it can contain .redo/top as an alternative)`)
136         if cmd == CmdNameRedo || cmd == CmdNameRedoIfchange {
137                 fmt.Fprintln(os.Stderr, `
138   REDO_NO_SYNC -- disable files/directories explicit filesystem syncing
139   REDO_INODE_TRUST -- {none,ctime,mtime}, either do not trust inode
140                       information at all (always check size and hash), or
141                       trust its ctime (the default one), or be satisfied
142                       with its mtime
143   REDO_MAKE -- bmake/gmake/none(default) jobserver protocol compatibility`)
144         }
145 }