github.com/solo-io/cue@v0.4.7/pkg/tool/file/file.cue (about)

     1  // Copyright 2018 The CUE Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package file
    16  
    17  // Read reads the contents of a file.
    18  Read: {
    19  	$id: "tool/file.Read"
    20  
    21  	// filename names the file to read.
    22  	//
    23  	// Relative names are taken relative to the current working directory.
    24  	// Slashes are converted to the native OS path separator.
    25  	filename: !=""
    26  
    27  	// contents is the read contents. If the contents are constraint to bytes
    28  	// (the default), the file is read as is. If it is constraint to a string,
    29  	// the contents are checked to be valid UTF-8.
    30  	contents: *bytes | string
    31  }
    32  
    33  // Append writes contents to the given file.
    34  Append: {
    35  	$id: "tool/file.Append"
    36  
    37  	// filename names the file to append.
    38  	//
    39  	// Relative names are taken relative to the current working directory.
    40  	// Slashes are converted to the native OS path separator.
    41  	filename: !=""
    42  
    43  	// permissions defines the permissions to use if the file does not yet exist.
    44  	permissions: int | *0o666
    45  
    46  	// contents specifies the bytes to be written.
    47  	contents: bytes | string
    48  }
    49  
    50  // Create writes contents to the given file.
    51  Create: {
    52  	$id: "tool/file.Create"
    53  
    54  	// filename names the file to write.
    55  	//
    56  	// Relative names are taken relative to the current working directory.
    57  	// Slashes are converted to the native OS path separator.
    58  	filename: !=""
    59  
    60  	// permissions defines the permissions to use if the file does not yet exist.
    61  	permissions: int | *0o666
    62  
    63  	// contents specifies the bytes to be written.
    64  	contents: bytes | string
    65  }
    66  
    67  // Glob returns a list of files.
    68  Glob: {
    69  	$id: "tool/file.Glob"
    70  
    71  	// glob specifies the pattern to match files with.
    72  	//
    73  	// A relative pattern is taken relative to the current working directory.
    74  	// Slashes are converted to the native OS path separator.
    75  	glob: !=""
    76  	files: [...string]
    77  }