docs: Document functions sort, wildcard and wrap.
[goals.git] / docs / Goalfile.pod
1 =encoding utf8
2
3 =head1 NAME
4
5 Goalfile - introduction, tutorial, and reference for writing goal files
6
7 =head1 SUMMARY
8
9 =head1 INTRODUCTION
10
11 =head1 TUTORIAL
12
13 =head1 REFERENCE
14
15 =head2 Standard Functions
16
17 =head3 sort (list)
18
19 For example:
20
21  sort (["c", "b", "b", "a"]) ⇒ ["a", "b", "c"]
22
23 This takes a list of strings and sorts it, removing duplicates.
24
25 =head3 subst (from, to, text)
26
27 For example:
28
29  subst ("aa", "AA", "aabbccaa") ⇒ "AAbbccAA"
30  subst ("a.*c", "b", "aaacac") ⇒ "bb"
31
32 This function works something like make’s C<subst> function, except
33 that C<from> is a regular expression, specifically a L<sed(1)>
34 extended regular expression.
35
36 =head3 wildcard (pattern)
37
38 For example:
39
40  wildcard ("*.c") ⇒ ["bar.c", "foo.c"]
41
42 The single parameter is a wildcard which is expanded into a list of
43 files using ordinary globbing rules.
44
45 =head3 wrap (wrapper, list)
46
47 For example:
48
49  wrap ("*file", ["bar.c", "foo.c"]) ⇒ [*file("bar.c"), *file("foo.c")]
50
51 Each element in C<list> is wrapped into a call to C<wrapper(element)>.
52 There are two common uses for this: either to add explicit tactics
53 (such as C<*file>) to a plain list of strings as in the example above;
54 or to turn a list of strings into a list of goal or function calls.
55
56 =head1 SEE ALSO
57
58 L<goals(1)>.
59
60 =head1 AUTHORS
61
62 Richard W.M. Jones <rjones@redhat.com>
63
64 =head1 COPYRIGHT
65
66 Copyright (C) 2020 Richard W.M. Jones
67
68 Copyright (C) 2020 Red Hat Inc.
69
70 This program is free software; you can redistribute it and/or modify
71 it under the terms of the GNU General Public License as published by
72 the Free Software Foundation; either version 2 of the License, or
73 (at your option) any later version.
74
75 This program is distributed in the hope that it will be useful,
76 but WITHOUT ANY WARRANTY; without even the implied warranty of
77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
78 GNU General Public License for more details.
79
80 You should have received a copy of the GNU General Public License along
81 with this program; if not, write to the Free Software Foundation, Inc.,
82 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.