File: tool.cue

package info (click to toggle)
golang-github-cue-lang-cue 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,644 kB
  • sloc: makefile: 20; sh: 15
file content (79 lines) | stat: -rw-r--r-- 2,537 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2018 The CUE Authors
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package tool

// A Command specifies a user-defined command.
//
// Descriptions are derived from the doc comment, if they are not provided
// structurally, using the following format:
//
//    // short description on one line
//    //
//    // Usage: <name> usage (optional)
//    //
//    // long description covering the remainder of the doc comment.
//
Command: {
	// Tasks specifies the things to run to complete a command. Tasks are
	// typically underspecified and completed by the particular internal
	// handler that is running them. Tasks can be a single task, or a full
	// hierarchy of tasks.
	//
	// Tasks that depend on the output of other tasks are run after such tasks.
	// Use `$after` if a task needs to run after another task but does not
	// otherwise depend on its output.
	Tasks

	// $usage summarizes how a command takes arguments.
	//
	// Example:
	//     mycmd [-n] names
	$usage?: string

	// $short is short description of what the command does.
	$short?: string

	// $long is a longer description that spans multiple lines and
	// likely contain examples of usage of the command.
	$long?: string
}

// TODO:
// - child commands?

// Tasks defines a hierarchy of tasks. A command completes if all tasks have
// run to completion.
Tasks: Task | {
	[name=Name]: Tasks
}

// #Name defines a valid task or command name.
Name: =~#"^\PL([-](\PL|\PN))*$"#

// A Task defines a step in the execution of a command.
Task: {
	// $id indicates the operation to run. Do not use this field directly;
	// instead unify with a task imported from one of the tool packages.
	$id: =~#"\."#

	// $after can be used to specify a task is run after another one,
	// when it does not otherwise refer to an output of that task.
	$after?: Task | [...Task]
}

// TODO: consider these options:
//   $success: bool
//   $runif: a.b.$success or $guard: a.b.$success
// With this `$after: a.b` would just be a shorthand for `$guard: a.b.$success`.