Skip to content

Commit 4c9c7c3

Browse files
Merge pull request #415 from OpenFn/413-update-cli
update to cli docs given cli v1.0.0 release
2 parents 1c8b023 + 1e811a0 commit 4c9c7c3

File tree

3 files changed

+163
-148
lines changed

3 files changed

+163
-148
lines changed

docs/build-for-developers/cli-intro.md

+27-24
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ simple to install, works on macOS, Windows, and Linux, and offers a range of
1212
functionality to enhance your developer experience with OpenFn. You can use the
1313
OpenFn CLI to:
1414

15-
- Securely run OpenFn jobs and workflows
16-
- Troubleshoot and debug OpenFn jobs
15+
- Securely run OpenFn steps and workflows
16+
- Troubleshoot and debug OpenFn steps
1717
- Deployment of workflows to OpenFn
1818

1919
---
@@ -32,8 +32,8 @@ Before you begin with the @openfn/cli, make sure to follow these simple steps:
3232
[Install Node.js](https://kinsta.com/blog/how-to-install-node-js/) by
3333
following this guide.
3434
3. **Understand OpenFn Basics:** Have a basic understanding of OpenFn,
35-
particularly jobs and adaptors. Check out the
36-
[Intro section](/documentation) on this site.
35+
particularly steps and adaptors. Check out the [Intro section](/documentation)
36+
on this site.
3737

3838
---
3939

@@ -58,20 +58,24 @@ command.
5858

5959
<details><summary>Expand to see the expected output.</summary>
6060

61-
[CLI] ℹ Versions:
62-
▸ node.js 18.12.1
63-
▸ cli 0.4.11
64-
▸ runtime 0.2.2
65-
▸ compiler 0.0.38
66-
[CLI] ℹ Running test job...
67-
[CLI] ℹ Workflow object:
61+
[CLI] ♦ Versions:
62+
▸ node.js 18.12.1
63+
▸ cli 1.0.0
64+
[CLI] ℹ Running test workflow...
65+
66+
[CLI] ℹ Execution plan:
6867
[CLI] ℹ {
69-
"start": "start",
70-
"jobs": [
68+
"options": {
69+
"start": "start"
70+
},
71+
"workflow": {
72+
"steps": [
7173
{
7274
"id": "start",
75+
"state": {
7376
"data": {
74-
"defaultAnswer": 42
77+
"defaultAnswer": 42
78+
}
7579
},
7680
"expression": "const fn = () => (state) => { console.log('Starting computer...'); return state; }; fn()",
7781
"next": {
@@ -91,19 +95,18 @@ command.
9195
}
9296
]
9397
}
98+
}
9499

95-
[CLI] ✔ Compilation complete
96-
[R/T] ♦ Starting job start
100+
[CLI] ✔ Compiled all expressions in workflow
101+
[R/T] ℹ Executing undefined
102+
[R/T] ℹ Starting step start
97103
[JOB] ℹ Starting computer...
98-
[R/T] ℹ Operation 1 complete in 0ms
99-
[R/T] ✔ Completed job start in 1ms
100-
[R/T] ♦ Starting job calculate
104+
[R/T] ✔ Completed step start in 1ms
105+
[R/T] ℹ Starting step calculate
101106
[JOB] ℹ Calculating to life, the universe, and everything..
102-
[R/T] ℹ Operation 1 complete in 0ms
103-
[R/T] ✔ Completed job calculate in 1ms
104-
[R/T] ♦ Starting job result
105-
[R/T] ℹ Operation 1 complete in 0ms
106-
[R/T] ✔ Completed job result in 0ms
107+
[R/T] ✔ Completed step calculate in 1ms
108+
[R/T] ℹ Starting step result
109+
[R/T] ✔ Completed step result in 0ms
107110
[CLI] ✔ Result: 42
108111

109112
</details>

docs/build-for-developers/cli-usage.md

+33-28
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ slug: /cli-usage
66

77
#### Execute a job, run a workflow, adjust logging, maintain adaptors, and save the state.
88

9-
You're probably here to run jobs (expressions) or workflows, which the CLI makes
10-
easy. Keep reading for an outline of the basic usage scenarios of the CLI.
9+
You're probably here to run steps (expressions) or workflows, which the CLI
10+
makes easy. Keep reading for an outline of the basic usage scenarios of the CLI.
1111

1212
---
1313

@@ -17,25 +17,24 @@ To run a single job, you must explicitly specify which adaptor to use. You can
1717
find the list of publicly available [adaptors here](/adaptors). See examples
1818
below.
1919

20-
> Pass the `-i` flag to auto-install that adaptor (it's safe to do this
21-
> redundantly).
20+
> Adaptors are auto-installed if the specified version is not detected.
2221
2322
**Use a shorthand (e.g., `http`):**
2423

2524
```bash
26-
openfn path/to/job.js -ia http
25+
openfn path/to/job.js -a http
2726
```
2827

2928
**Use the full package name (e.g., `@openfn/language-http`):**
3029

3130
```bash
32-
openfn path/to/job.js -ia @openfn/language-http
31+
openfn path/to/job.js -a @openfn/language-http
3332
```
3433

3534
**Add a specific version:**
3635

3736
```bash
38-
openfn path/to/job.js -ia [email protected]
37+
openfn path/to/job.js -a [email protected]
3938
```
4039

4140
**Pass a path to a locally installed adaptor:**
@@ -54,15 +53,15 @@ it creates an `output.json` next to the job file.
5453
**You can specify custom paths for the output and state files:**
5554

5655
```bash
57-
openfn path/to/job.js -ia adaptor-name -o path/to/output.json -s path/to/state.json
56+
openfn path/to/job.js -a adaptor-name -o path/to/output.json -s path/to/state.json
5857
```
5958

6059
### Return resulting state through stdout
6160

6261
**Use `-O` to return the output through stdout:**
6362

6463
```bash
65-
openfn path/to/job.js -ia adaptor-name -O
64+
openfn path/to/job.js -a adaptor-name -O
6665
```
6766

6867
---
@@ -98,7 +97,7 @@ export OPENFN_REPO_DIR=/path/to/repo
9897
**Auto-install adaptors and check if a matching version is found in the repo:**
9998

10099
```bash
101-
openfn path/to/job.js -ia adaptor-name
100+
openfn path/to/job.js -a adaptor-name
102101
```
103102

104103
**Remove all adaptors from the repo:**
@@ -116,25 +115,31 @@ openfn repo clean
116115

117116
```json
118117
{
119-
"start": "a", // optionally specify the start node (defaults to jobs[0])
120-
"jobs": [
121-
{
122-
"id": "a",
123-
"expression": "fn((state) => state)", // code or a path
124-
"adaptor": "@openfn/[email protected]", // specifiy the adaptor to use (version optional)
125-
"data": {}, // optionally pre-populate the data object (this will be overriden by keys in in previous state)
126-
"configuration": {}, // Use this to pass credentials
127-
"next": {
128-
// This object defines which jobs to call next
129-
// All edges returning true will run
130-
// If there are no next edges, the workflow will end
131-
"b": true,
132-
"c": {
133-
"condition": "!state.error" // Note that this is an expression, not a function
118+
"options": {
119+
"start": "a" // optionally specify the start node (defaults to steps[0])
120+
},
121+
"workflows": {
122+
"steps": [
123+
{
124+
"id": "a",
125+
"expression": "fn((state) => state)", // code or a path
126+
"adaptor": "@openfn/[email protected]", // specifiy the adaptor to use (version optional)
127+
"state": {
128+
"data": {} // optionally pre-populate the data object (this will be overriden by keys in in previous state)
129+
},
130+
"configuration": {}, // Use this to pass credentials
131+
"next": {
132+
// This object defines which steps to call next
133+
// All edges returning true will run
134+
// If there are no next edges, the workflow will end
135+
"b": true,
136+
"c": {
137+
"condition": "!state.error" // Note that this is an expression, not a function
138+
}
134139
}
135140
}
136-
}
137-
]
141+
]
142+
}
138143
}
139144
```
140145

@@ -143,7 +148,7 @@ openfn repo clean
143148
**To run a workflow:**
144149

145150
```bash
146-
openfn path/to/workflow.json -i
151+
openfn path/to/workflow.json -o tmp/output.json
147152
```
148153

149154
Check out this detailed [tutorial](cli-walkthrough#7-running-workflows) on

0 commit comments

Comments
 (0)