stdlib: Implement dirname(), basename() and extension() functions.
[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 basename (path)
18
19 For example:
20
21  basename ("dir/file.ext") ⇒ "file.ext"
22
23 Returns the filename part of the path.
24
25 =head3 dirname (path)
26
27 For example:
28
29  dirname ("dir/file.ext") ⇒ "dir"
30
31 Returns the directory part of the path.
32
33 =head3 extension (filename)
34
35 For example:
36
37  extension ("dir/file.ext") ⇒ "ext"
38
39 Returns the filename extension.
40
41 =head3 sort (list)
42
43 For example:
44
45  sort (["c", "b", "b", "a"]) ⇒ ["a", "b", "c"]
46
47 This takes a list of strings and sorts it, removing duplicates.
48
49 =head3 subst (from, to, text)
50
51 For example:
52
53  subst ("aa", "AA", "aabbccaa") ⇒ "AAbbccAA"
54  subst ("a.*c", "b", "aaacac") ⇒ "bb"
55
56 This function works something like make’s C<subst> function, except
57 that C<from> is a regular expression, specifically a L<sed(1)>
58 extended regular expression.
59
60 =head3 wildcard (pattern)
61
62 For example:
63
64  wildcard ("*.c") ⇒ ["bar.c", "foo.c"]
65
66 The single parameter is a wildcard which is expanded into a list of
67 files using ordinary globbing rules.
68
69 =head3 wrap (wrapper, list)
70
71 For example:
72
73  wrap ("*file", ["bar.c", "foo.c"]) ⇒ [*file("bar.c"), *file("foo.c")]
74
75 Each element in C<list> is wrapped into a call to C<wrapper(element)>.
76 There are two common uses for this: either to add explicit tactics
77 (such as C<*file>) to a plain list of strings as in the example above;
78 or to turn a list of strings into a list of goal or function calls.
79
80 =head1 SEE ALSO
81
82 L<goals(1)>.
83
84 =head1 AUTHORS
85
86 Richard W.M. Jones <rjones@redhat.com>
87
88 =head1 COPYRIGHT
89
90 Copyright (C) 2020 Richard W.M. Jones
91
92 Copyright (C) 2020 Red Hat Inc.
93
94 This program is free software; you can redistribute it and/or modify
95 it under the terms of the GNU General Public License as published by
96 the Free Software Foundation; either version 2 of the License, or
97 (at your option) any later version.
98
99 This program is distributed in the hope that it will be useful,
100 but WITHOUT ANY WARRANTY; without even the implied warranty of
101 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
102 GNU General Public License for more details.
103
104 You should have received a copy of the GNU General Public License along
105 with this program; if not, write to the Free Software Foundation, Inc.,
106 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.