Skip to content

Commit

Permalink
docs/howto: influence workflow command task order
Browse files Browse the repository at this point in the history
Fixes cue-lang/docs-and-content#124.

Preview-Path: /docs/howto/influence-workflow-command-task-order/
Signed-off-by: Paul Jolly <[email protected]>
Change-Id: Iada6f005cc9ab4f5cd029a769efc268074a62b50
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cuelang.org/+/1203072
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
myitcv authored and jpluscplusm committed Nov 12, 2024
1 parent 471ea8d commit 4ec1883
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
55 changes: 55 additions & 0 deletions content/docs/howto/influence-workflow-command-task-order/en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Influencing the order of tasks in a workflow command
toc_hide: true
authors: [myitcv]
tags: [workflow command]
---

This [Commented CUE]({{< relref "docs/howto/about-commented-cue-guides" >}})
demonstrates how to use dependencies to influence the order of execution of
tasks in a workflow command.

{{{with code "en" "cc"}}}
#location top top bottom
exec cue cmd doStuff
cmp stdout out
-- some_tool.cue --
package example

import (
"strings"
"tool/cli"
"tool/file"
)

command: doStuff: {
// The readFile task reads a greeting from a file.
readFile: file.Read & {
filename: "input.txt"
contents: string
}

// The echoGreeting task prints the greeting read by readFile.
echoGreeting: cli.Print & {
text: "We read: \(strings.TrimSpace(readFile.contents))"
}

// The thankUser task prints a message after both readFile and echoGreeting are finished.
thankUser: cli.Print & {
$after: [readFile, echoGreeting]
text: "Thank you"
}
}
-- input.txt --
Hello, world!
-- out --
We read: Hello, world!
Thank you
{{{end}}}

## Related content

- {{<linkto/related/howto "use-your-first-cue-workflow-command" >}}
-- getting started with workflow commands
- {{<linkto/related/reference "command/cue-help-commands">}}
- {{<linkto/related/reference "command/cue-help-cmd">}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package site
{
content: {
docs: {
howto: {
"influence-workflow-command-task-order": {
page: {
cache: {
code: {
cc: "Gjzsk+dVviHn1zJwNtQ6iigBQf3aT/y00aQnEfPSCUA="
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package site

content: docs: howto: "influence-workflow-command-task-order": page: _
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: Influencing the order of tasks in a workflow command
toc_hide: true
authors: [myitcv]
tags: [workflow command]
---

This [Commented CUE]({{< relref "docs/howto/about-commented-cue-guides" >}})
demonstrates how to use dependencies to influence the order of execution of
tasks in a workflow command.

{{< code-tabs >}}
{{< code-tab name="some_tool.cue" language="cue" area="top" >}}
package example

import (
"strings"
"tool/cli"
"tool/file"
)

command: doStuff: {
// The readFile task reads a greeting from a file.
readFile: file.Read & {
filename: "input.txt"
contents: string
}

// The echoGreeting task prints the greeting read by readFile.
echoGreeting: cli.Print & {
text: "We read: \(strings.TrimSpace(readFile.contents))"
}

// The thankUser task prints a message after both readFile and echoGreeting are finished.
thankUser: cli.Print & {
$after: [readFile, echoGreeting]
text: "Thank you"
}
}
{{< /code-tab >}}
{{< code-tab name="input.txt" language="txt" area="top" >}}
Hello, world!
{{< /code-tab >}}
{{< code-tab name="TERMINAL" language="" area="bottom" type="terminal" codetocopy="Y3VlIGNtZCBkb1N0dWZm" >}}
$ cue cmd doStuff
We read: Hello, world!
Thank you
{{< /code-tab >}}
{{< /code-tabs >}}

## Related content

- {{<linkto/related/howto "use-your-first-cue-workflow-command" >}}
-- getting started with workflow commands
- {{<linkto/related/reference "command/cue-help-commands">}}
- {{<linkto/related/reference "command/cue-help-cmd">}}

0 comments on commit 4ec1883

Please sign in to comment.