cue: some API adjustments for new-style definitions
The API is now rather unsuitable for handling definitions.
Add some temporary workarounds until we have a new API.
Also updates some old-style defintions to new style.
Change-Id: Ib5c3210016aca971c45c7eddbc9dcb65f7fdc4e1
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6000
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/pkg/tool/doc.go b/pkg/tool/doc.go
index 51e62b2..6475f97 100644
--- a/pkg/tool/doc.go
+++ b/pkg/tool/doc.go
@@ -52,18 +52,19 @@
// // long is a longer description that spans multiple lines and
// // likely contain examples of usage of the command.
// $long?: string
-//
-// // TODO: child commands.
// }
//
+// // 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 sname.
-// Name :: =~#"^\PL(\PL|\PN|-(\PL|\PN))*$"#
+// // #Name defines a valid task or command name.
+// Name: =~#"^\PL([-](\PL|\PN))*$"#
//
// // A Task defines a step in the execution of a command.
// Task: {
@@ -72,6 +73,15 @@
// // kind indicates the operation to run. It must be of the form
// // packagePath.Operation.
// $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`.
+//
package tool
diff --git a/pkg/tool/os/doc.go b/pkg/tool/os/doc.go
index b32321f..b4a66c1 100644
--- a/pkg/tool/os/doc.go
+++ b/pkg/tool/os/doc.go
@@ -6,10 +6,10 @@
//
// // A Value are all possible values allowed in flags.
// // A null value unsets an environment variable.
-// Value :: bool | number | *string | null
+// Value: bool | number | *string | null
//
// // Name indicates a valid flag name.
-// Name :: !="" & !~"^[$]"
+// Name: !="" & !~"^[$]"
//
// // Setenv defines a set of command line flags, the values of which will be set
// // at run time. The doc comment of the flag is presented to the user in help.
@@ -19,14 +19,14 @@
// Setenv: {
// $id: "tool/os.Setenv"
//
-// [Name]: Value
+// {[Name]: Value}
// }
//
// // Getenv gets and parses the specific command line variables.
// Getenv: {
// $id: "tool/os.Getenv"
//
-// [Name]: Value
+// {[Name]: Value}
// }
//
// // Environ populates a struct with all environment variables.
@@ -37,7 +37,7 @@
// // Individual entries may be specified ahead of time to enable
// // validation and parsing. Values that are marked as required
// // will fail the task if they are not found.
-// [Name]: Value
+// {[Name]: Value}
// }
//
// // Clearenv clears all environment variables.
diff --git a/pkg/tool/os/os.cue b/pkg/tool/os/os.cue
index 6881bd9..56e1724 100644
--- a/pkg/tool/os/os.cue
+++ b/pkg/tool/os/os.cue
@@ -1,11 +1,11 @@
// Copyright 2019 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.
@@ -16,10 +16,10 @@
// A Value are all possible values allowed in flags.
// A null value unsets an environment variable.
-Value :: bool | number | *string | null
+Value: bool | number | *string | null
// Name indicates a valid flag name.
-Name :: !="" & !~"^[$]"
+Name: !="" & !~"^[$]"
// Setenv defines a set of command line flags, the values of which will be set
// at run time. The doc comment of the flag is presented to the user in help.
diff --git a/pkg/tool/tool.cue b/pkg/tool/tool.cue
index ed0bf2f..bac14b8 100644
--- a/pkg/tool/tool.cue
+++ b/pkg/tool/tool.cue
@@ -58,8 +58,8 @@
[name=Name]: Tasks
}
-// Name defines a valid task or command name.
-Name :: =~#"^\PL([-](\PL|\PN))*$"#
+// #Name defines a valid task or command name.
+Name: =~#"^\PL([-](\PL|\PN))*$"#
// A Task defines a step in the execution of a command.
Task: {