5 Goalfile - introduction, tutorial, and reference for writing goal files
15 =head2 Standard Functions
17 =head3 basename (path)
21 basename ("dir/file.ext") ⇒ "file.ext"
23 Returns the filename part of the path.
29 dirname ("dir/file.ext") ⇒ "dir"
31 Returns the directory part of the path.
33 =head3 extension (filename)
37 extension ("dir/file.ext") ⇒ "ext"
39 Returns the filename extension.
45 head (["a", "b", "c"]) ⇒ "a"
47 Returns the head (first) element of the list.
49 =head3 join (list1, list2)
53 join (["a", "b"], ["c", "d"]) ⇒ ["a", "b", "c", "d"]
55 Concatenate C<list1> and C<list2>. It's not usually necessary to use
56 this function since goals automatically flattens lists within lists
57 into simple lists in many cases.
59 =head3 read (filename)
63 read ("filename") => "this is the content of filename"
65 Read the contents of C<filename> and return it as a single string.
66 If there is a trailing C<\n> in the file it is truncated.
68 =head3 readlines (filename)
72 readlines ("filename") => ["line1", "line2", "line3"]
74 Read the lines in C<filename> returning a list of strings.
76 =head3 realpath (filename)
80 realpath ("./tests") ⇒ "/home/user/tests"
82 Run the L<realpath(1)> command to return the resolved absolute path of
83 the C<filename> parameter.
89 sort (["c", "b", "b", "a"]) ⇒ ["a", "b", "c"]
91 This takes a list of strings and sorts it, removing duplicates.
93 =head3 subst (from, to, text)
97 subst ("aa", "AA", "aabbccaa") ⇒ "AAbbccAA"
98 subst ("a.*c", "b", "aaacac") ⇒ "bb"
100 This function works something like make’s C<subst> function, except
101 that C<from> is a regular expression, specifically a L<sed(1)>
102 extended regular expression.
108 tail (["a", "b", "c"]) ⇒ ["b", "c"]
110 Returns the tail (all except first) elements of the list.
112 =head3 wildcard (pattern)
116 wildcard ("*.c") ⇒ ["bar.c", "foo.c"]
118 The single parameter is a wildcard which is expanded into a list of
119 files using ordinary globbing rules.
121 =head3 wrap (wrapper, list)
125 wrap ("*file", ["bar.c", "foo.c"]) ⇒ [*file("bar.c"), *file("foo.c")]
127 Each element in C<list> is wrapped into a call to C<wrapper(element)>.
128 There are two common uses for this: either to add explicit tactics
129 (such as C<*file>) to a plain list of strings as in the example above;
130 or to turn a list of strings into a list of goal or function calls.
138 Richard W.M. Jones <rjones@redhat.com>
142 Copyright (C) 2020 Richard W.M. Jones
144 Copyright (C) 2020 Red Hat Inc.
146 This program is free software; you can redistribute it and/or modify
147 it under the terms of the GNU General Public License as published by
148 the Free Software Foundation; either version 2 of the License, or
149 (at your option) any later version.
151 This program is distributed in the hope that it will be useful,
152 but WITHOUT ANY WARRANTY; without even the implied warranty of
153 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
154 GNU General Public License for more details.
156 You should have received a copy of the GNU General Public License along
157 with this program; if not, write to the Free Software Foundation, Inc.,
158 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.