github.com/solo-io/cue@v0.4.7/pkg/tool/tool.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 tool 16 17 // A Command specifies a user-defined command. 18 // 19 // Descriptions are derived from the doc comment, if they are not provided 20 // structurally, using the following format: 21 // 22 // // short description on one line 23 // // 24 // // Usage: <name> usage (optional) 25 // // 26 // // long description covering the remainder of the doc comment. 27 // 28 Command: { 29 // Tasks specifies the things to run to complete a command. Tasks are 30 // typically underspecified and completed by the particular internal 31 // handler that is running them. Tasks can be a single task, or a full 32 // hierarchy of tasks. 33 // 34 // Tasks that depend on the output of other tasks are run after such tasks. 35 // Use `$after` if a task needs to run after another task but does not 36 // otherwise depend on its output. 37 Tasks 38 39 // 40 // Example: 41 // mycmd [-n] names 42 $usage?: string 43 44 // short is short description of what the command does. 45 $short?: string 46 47 // long is a longer description that spans multiple lines and 48 // likely contain examples of usage of the command. 49 $long?: string 50 } 51 52 // TODO: 53 // - child commands? 54 55 // Tasks defines a hierarchy of tasks. A command completes if all tasks have 56 // run to completion. 57 Tasks: Task | { 58 [name=Name]: Tasks 59 } 60 61 // #Name defines a valid task or command name. 62 Name: =~#"^\PL([-](\PL|\PN))*$"# 63 64 // A Task defines a step in the execution of a command. 65 Task: { 66 $type: "tool.Task" // legacy field 'kind' still supported for now. 67 68 // kind indicates the operation to run. It must be of the form 69 // packagePath.Operation. 70 $id: =~#"\."# 71 72 // $after can be used to specify a task is run after another one, when 73 // it does not otherwise refer to an output of that task. 74 $after?: Task | [...Task] 75 } 76 77 // TODO: consider these options: 78 // $success: bool 79 // $runif: a.b.$success or $guard: a.b.$success 80 // With this `$after: a.b` would just be a shorthand for `$guard: a.b.$success`.