1 # SPDX-License-Identifier: GPL-3.0-only
5 manual_title = Games Manual
7 [supercommand tfortune]
16 synopsis = [global-options...] [--] [<subcommand> [subcommand-options...]]
18 summary = print help and exit
20 [option detailed-help]
21 summary = print help, including all details, and exit
23 summary = print version and exit
26 summary = control amount of logging
28 arg_info = required_arg
32 LSGLL_DEBUG = "debug",
34 LSGLL_NOTICE = "notice",
35 LSGLL_WARNING = "warning",
36 LSGLL_ERROR = "error",
42 Log only messages with severity greater or equal than the given
43 value. Possible values:
45 debug: Produces really noisy output.
46 info: Still noisy, but won't fill up the disk quickly.
47 notice: Indicates normal, but significant event.
48 warning: Unexpected events that can be handled.
49 error: Unhandled error condition.
50 crit: System might be unreliable.
51 emerg: Last message before exit.
54 summary = where to look for input files
56 arg_info = required_arg
59 default_val = "~/.tfortune"
61 This is used to locate epigrams and named tag expressions.
62 If any filename argument does not start with a slash, the
63 filename is interpreted as relative to this base directory.
65 Epigrams are expected in the "epigrams" subdirectory of the base
66 directory while tag expressions are expected to be stored below
69 If the option is not given, and the per-user epigram directory does
70 not exist, the system-wide default DATADIR() is tried. There is no
71 such fallback for tag expressions, though.
75 purpose = perform bash command line completion
76 non-opts-name = arg...
78 This subcommand is executed from the bash completer for tfortune. The
79 completer sets the non-option arguments for the subcommand to the
80 words of the current command line. It obtains these words from the
81 elements of the special COMP_WORDS array which is maintained by bash.
83 The compgen subcommand writes all possible completions to stdout. The
84 completer reads in the completions and builds the COMPREPLY array
85 containing the matching entries. Bash examines the elements of this
86 array and completes the command line if there is a single matching
87 completion, or prints out the list of completions in case of ambiguity.
90 [option current-word-index]
92 summary = index of the current word in the command line
94 arg_info = required_arg
97 An index into the argument vector of the word containing the current
98 cursor position. See the description of the $CWORD special variable
102 [subcommand completer]
103 purpose = print the bash completer to stdout
105 The output of this command is designed to be re-used as input for bash.
106 Specifically, bash completion for tfortune can be activated by adding
107 the following to .bashrc: eval "$(tfortune completer)".
110 summary = also add an alias and a completer for it
112 arg_info = required_arg
116 Specify this to define a bash alias for tfortune along with the
117 completer. Unlike the regular tfortune program, the alias will
118 contain the double dash argument which separates the subcommand and
119 its options from the options to tfortune itself.
123 purpose = edit epigrams
124 non-opts-name = basename...
126 Opens the named epigram file an interactive editor. The executable
127 of the editor is determined as follows: First the contents of the
128 environment variable TFORTUNE_EDITOR is examined. If this variable
129 is empty or unset, EDITOR is tried. If EDITOR is also unset, vi
132 The given basename is interpreted as described in the help text of the
133 --basedir option above. If --basedir is not given and the "epigrams"
134 directory does not exist, it is created.
138 purpose = edit tag expressions
139 non-opts-name = basename...
141 Opens the named tag expression file an interactive editor. The editor
142 to execute is determined in the same way as for the "ede" subcommand.
143 Also, a non-existing "expressions" subdirectory is handled in the same
147 purpose = list available subcommands or print command-specific help
148 non-opts-name = [command]
150 Without any arguments, help prints the list of available commands. When
151 called with a command name argument, it prints the help text of the
156 summary = show the long help text
158 If the optional argument is supplied, the long help text contains the
159 synopsis, the purpose and the description of the specified command,
160 followed by the option list including summary and help text of each
161 option. Without --long, the short help is shown instead. This omits
162 the description of the command and the option help.
164 If no command is supplied but --long is given, the list contains the
165 purpose of each command.
169 purpose = list epigram files
171 Print the list of all epigram files.
175 summary = long listing
177 This is similar to the long output of the standard ls(1) command.
183 This lists all tags contained in any of the given input files.
185 non-opts-name = <file>...
188 summary = long listing
190 Also show how many times this tag appears.
192 [option sort-by-count]
194 summary = sort by occurrence count rather than alphabetically.
197 summary = reverse sort order
200 purpose = list tag expressions
202 Print the list of all named tag expressions.
206 summary = long listing
208 This is similar to the long output of the standard ls(1) command.
211 purpose = print epigram(s)
213 Unless --all is given, this picks an epigram by random from the
214 given file(s) which is admissible with respect to the given named
215 tag expression. If no file is given, all files are taken into account.
217 non-opts-name = [file...]
220 summary = name of the tag expression
221 arg_info = required_arg
224 default_val = /dev/null
226 Use the tag expression stored in the given file to define the
227 admissible epigrams. The special string "-" means to read the tag
228 expression from stdin. The default value corresponds to the empty
229 tag expression for which all epigrams are admissible.
233 summary = print all admissible epigrams, not just a random one.
236 summary = print also the tags of the selected epigram
238 purpose = show statistics
240 This prints several counts and averages about the epigrams, tags and
245 summary = include statistics about hash table utilization
247 [section Input file format]
248 Input files may contain arbitrary many epigrams. The end of each
249 epigram must be marked with a "tag" line. The tag line consists of
250 four dashes, a space character, and a comma separated list of tags.
251 Tags may span multiple words, but no comma is allowed. The following
252 is an example input file for tfortune. It contains a single epigram
257 Anyone who attempts to generate random numbers by deterministic means
258 is, of course, living in a state of sin. -- John von Neumann
264 [section Tag Expressions]
265 Tag expressions are based on a context-free grammar in which the
266 following keywords are defined:
271 if the epigram contains a tag named
277 evaluates to the number of bytes of the epigram.
280 evaluates to contents of the epigram. This is useful for pattern
284 The grammar admits the following operators and relations:
289 logical operators for
299 arithmetic operators for addition, negation or subtraction (unary
300 or binary minus), multiplication and division. Arithmetic is always
301 performed on 64 bit signed integers.
310 less than, greater than, less or equal than, greater or equal than,
311 equal to, not equal to, regular expression match.
312 Regular expression patterns are of the form
313 .IR /pattern/[flags] .
314 That is, the pattern is delimited by slashes, and is followed by
315 zero or more characters, each specifying a flag according to the
324 Treat newline as an ordinary character
329 Note that only extended regular expression patterns are supported. See
330 regex(3) for details.
333 The above operators obey the usual associativity and precedence
334 rules. Parentheses can be used to change precedence.
338 is an expression in this grammar which evaluates to either
342 Epigrams for which the expression is
347 For example, the above epigram is admissible for the tag expression
351 (tag("math") || tag("physics")) && len < 1000 && text =~ /neumann/i
355 It is not admissible for
359 (tag("math") && tag("physics")) || len > 1000 || text =~ /neumann/
366 Print a random epigram:
374 Print a random short (less than 100 bytes) epigram:
378 echo 'len < 100' | tfortune -l debug -- print -x -
382 List tags, including usage counts, sort by count in descending order:
390 Activate bash completion and define the
396 eval "$(tfortune completer -a tf)"
405 Copyright (C) COPYRIGHT_YEAR() AUTHOR()
409 This is free software: you are free to change and redistribute it.
411 There is NO WARRANTY, to the extent permitted by law.
414 .UR PACKAGE_HOMEPAGE()