Skip to content

Commit 4a1e5ec

Browse files
authored
fix: squash a couple library view bugs and update docs (#167)
1 parent d5c1aed commit 4a1e5ec

File tree

17 files changed

+141
-70
lines changed

17 files changed

+141
-70
lines changed

docs/README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ operations workflows.
1010

1111
**This project is currently in beta and documentation is a work in progress.** Contributions and feedback are welcome.
1212

13-
## Features <!-- {docsify-ignore} -->
13+
#### _Features_ <!-- {docsify-ignore} -->
1414

1515
- **Task Runner**: Easily define, manage, and run your tasks (called [executables](guide/executable.md)) from the command line.
1616
- **Secret Vault**: Store sensitive secrets in a secure local [vault](guide/vault.md).
@@ -19,3 +19,8 @@ operations workflows.
1919
- **Executable Organizer**: Group, reference, and search for executables by workspace, namespace, verbs, and tags.
2020
- **Input Handler**: Pass values into executables with environment variables defined by secrets, command-line args, or interactive prompts.
2121
- **Customizable TUI**: Personalize your [TUI experience](guide/interactive.md) with settings for log formatting, log archiving, and execution notifications, and more.
22+
23+
---
24+
25+
<p align="center"><img src="_media/demo.gif" width="1600"></p>
26+

docs/_media/demo.gif

2.95 MB
Loading

docs/demo.tape

+22-11
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,43 @@
5656
# Show Show the subsequent commands in the output
5757

5858
Output demo.gif
59-
Require flow
60-
61-
# Setup
59+
Set WindowBar Colorful
60+
Set WindowBarSize 80
6261
Set Shell "bash"
63-
Set FontSize 32
64-
Set Width 3200
62+
Set FontSize 28
63+
Set Width 3400
6564
Set Height 1200
65+
Set PlaybackSpeed 0.5
66+
Set Padding 20
6667

6768
# Launch flow library
69+
Hide
70+
Env DISABLE_FLOW_INTERACTIVE "false"
71+
Type "go build -o .bin/flow"
72+
Enter
73+
Type "alias flow=.bin/flow"
74+
Enter
75+
Type "clear"
76+
Enter
77+
Sleep 1s
78+
Show
6879
Type "flow library"
6980
Sleep 2s
7081
Enter
7182

7283
# Navigate to flow workspace / examples namespace
7384
Sleep 5s
74-
Down@1s
75-
Space@1s
76-
Sleep 5s
85+
Down@2s
86+
Space@2s
7787
Down@1s 3
7888
Sleep 3s
7989

8090
# Pick an executable to run
8191
Right@1s
82-
Sleep 2s
83-
Down@3s 5
92+
Sleep 3s
93+
Down@2s 5
94+
Sleep 3s
8495

8596
# Run the selected executable
8697
Type "r"
87-
Sleep 5s
98+
Sleep 15s

docs/docs.flow

+11
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,14 @@ executables:
3939
exec:
4040
dir: //
4141
cmd: docsify serve docs --open
42+
- verb: start
43+
name: recording
44+
aliases: [vhs]
45+
description: Record a demo of the Flow CLI and save it
46+
tags: [vhs]
47+
exec:
48+
params:
49+
- envKey: OUTPUT
50+
text: docs/_media/demo.gif
51+
dir: //
52+
cmd: vhs -o $OUTPUT docs/demo.tape

docs/quickstart.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A workspace can be created anywhere on your system but must be registered in ord
1111
To create a new workspace, run the following command in the directory where you want the workspace to be created:
1212

1313
```shell
14-
flow workspace create my-workspace .
14+
flow workspace create my-workspace . --set
1515
```
1616

1717
You can replace `my-workspace` with any name you want to give your workspace and `.` with the path to the root directory
@@ -47,6 +47,21 @@ executables:
4747
This flow file defines a single executable named `my-task`. When run, it will prompt the user for their favorite color
4848
and then echo that color back to the console.
4949

50+
**Add another workspace**
51+
52+
If you're new to flow, try adding the `flow` workspace and explore the executables it contains.
53+
54+
```shell
55+
git clone github.com/jahvon/flow
56+
flow workspace create flow flow
57+
```
58+
59+
When you have multiple workspaces, you can switch between them using a command like the following:
60+
61+
```shell
62+
flow workspace set flow
63+
```
64+
5065
**Running an executable**
5166

5267
Whenever you create, move, or delete executables and flow files, you will need to update the index of executables before running them.

docs/types/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ You can add the following comment to the top of your flow files to enable this:
1414
# yaml-language-server: $schema=https://flowexec.io/schemas/flowfile_schema.json
1515
```
1616

17-
See the [schemas directory on GitHub](https://github.com/jahvon/flow/tree/main/schemas) for all available schemas.
17+
See the [schemas directory on GitHub](https://github.com/jahvon/flow/tree/main/docs/schemas) for all available schemas.
1818

1919
Note: If using the flow file schema, you will need to make sure your IDE is configured to treat `*.flow` files as YAML files.

examples/parallel.flow

+25-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,28 @@ executables:
77
- verb: watch
88
name: parallel
99
parallel:
10-
refs:
11-
- run examples:with-output
12-
- run examples:with-input
13-
- run examples:from-file
10+
execs:
11+
- ref: run examples:with-output
12+
- ref: run examples:with-input
13+
- ref: run examples:from-file
14+
- verb: restart
15+
name: foo-sequence
16+
parallel:
17+
dir: f:tmp
18+
execs:
19+
- cmd: |
20+
echo "Creating foo.txt" 1>&2
21+
echo "foo bar baz" > foo.txt
22+
- cmd: |
23+
echo "Crunching the numbers..."
24+
echo "Number of files in current directory: $(ls | wc -l)"
25+
echo "Number of lines in this file: $(wc -l < foo.txt)"
26+
echo "Number of words in this file: $(wc -w < foo.txt)"
27+
- cmd: |
28+
echo "Reviewing the data..."
29+
sleep 2
30+
cat foo.txt
31+
sleep 2
32+
echo "Deleting foo.txt" 1>&2
33+
rm foo.txt
34+
- ref: run examples:with-output

examples/serial.flow

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ executables:
77
- verb: start
88
name: serial
99
serial:
10-
refs:
11-
- run examples:with-output
12-
- run examples:with-input
13-
- run examples:from-file
10+
execs:
11+
- ref: run examples:with-output
12+
- ref: run examples:with-input
13+
- ref: run examples:from-file

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/itchyny/gojq v0.12.16
1313
github.com/jahvon/glamour v0.8.1-patch1
1414
github.com/jahvon/open-golang v0.0.0-20240522004812-68511c3bc9ef
15-
github.com/jahvon/tuikit v0.0.23
15+
github.com/jahvon/tuikit v0.0.24
1616
github.com/mattn/go-runewidth v0.0.16
1717
github.com/onsi/ginkgo/v2 v2.20.2
1818
github.com/onsi/gomega v1.34.2

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ github.com/jahvon/glamour v0.8.1-patch1 h1:ahDSYbmhdKtrl0q/QxyshaFXnhUUBmuDCyJk1
9393
github.com/jahvon/glamour v0.8.1-patch1/go.mod h1:iGeJCQECnGJXk6X9D9UDUrtJ4hEUhYTIACdyNA2CAUk=
9494
github.com/jahvon/open-golang v0.0.0-20240522004812-68511c3bc9ef h1:4PS/MNVT6Rsv15x5Rtwaw971e6kFvNUAf9nvUsZ5hcc=
9595
github.com/jahvon/open-golang v0.0.0-20240522004812-68511c3bc9ef/go.mod h1:dUmuT5CN6osIeLSRtTPJOf0Yz+qAbcyU6omnCzI+ZfQ=
96-
github.com/jahvon/tuikit v0.0.23 h1:mvgFU0yFHYPqdTr+kFYmA6qUD3drh40KGhiNoC6ZXMk=
97-
github.com/jahvon/tuikit v0.0.23/go.mod h1:trQ4HzTqTwYkYinDSYIa/8XML9lxIuzYQpALJ0Y+p3w=
96+
github.com/jahvon/tuikit v0.0.24 h1:5c7wcZg+Qonv9K+r0xVLNzpzTibuHXwZAyAeXrvOYwQ=
97+
github.com/jahvon/tuikit v0.0.24/go.mod h1:trQ4HzTqTwYkYinDSYIa/8XML9lxIuzYQpALJ0Y+p3w=
9898
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
9999
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
100100
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=

internal/io/executable/views.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func NewExecutableView(
4141
if err := clipboard.WriteAll(exec.Ref().String()); err != nil {
4242
container.HandleError(fmt.Errorf("unable to copy reference to clipboard: %w", err))
4343
} else {
44-
container.SetNotice("copied reference to clipboard", styles.NoticeLevelInfo)
44+
container.SetNotice("copied reference to clipboard", styles.OutputLevelInfo)
4545
}
4646
return nil
4747
},
@@ -112,7 +112,7 @@ func NewTemplateView(
112112
if err := clipboard.WriteAll(template.Location()); err != nil {
113113
container.HandleError(fmt.Errorf("unable to copy location to clipboard: %w", err))
114114
} else {
115-
container.SetNotice("copied location to clipboard", styles.NoticeLevelInfo)
115+
container.SetNotice("copied location to clipboard", styles.OutputLevelInfo)
116116
}
117117
return nil
118118
},

internal/io/library/update.go

+24-24
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package library
33

44
import (
5+
"os"
56
"path/filepath"
67

78
"github.com/atotto/clipboard"
@@ -117,17 +118,17 @@ func (l *Library) updateWsPane(msg tea.Msg) (viewport.Model, tea.Cmd) {
117118
}
118119
case "o":
119120
if curWsCfg == nil {
120-
l.SetNotice("no workspace selected", styles.NoticeLevelError)
121+
l.SetNotice("no workspace selected", styles.OutputLevelError)
121122
break
122123
}
123124

124125
if err := open.Open(curWsCfg.Location(), false); err != nil {
125126
l.ctx.Logger.Error(err, "unable to open workspace")
126-
l.SetNotice("unable to open workspace", styles.NoticeLevelError)
127+
l.SetNotice("unable to open workspace", styles.OutputLevelError)
127128
}
128129
case "e":
129130
if curWsCfg == nil {
130-
l.SetNotice("no workspace selected", styles.NoticeLevelError)
131+
l.SetNotice("no workspace selected", styles.OutputLevelError)
131132
break
132133
}
133134

@@ -136,47 +137,47 @@ func (l *Library) updateWsPane(msg tea.Msg) (viewport.Model, tea.Cmd) {
136137
l.ctx.StdIn(), l.ctx.StdOut(),
137138
); err != nil {
138139
l.ctx.Logger.Error(err, "unable to open workspace in editor")
139-
l.SetNotice("unable to open workspace in editor", styles.NoticeLevelError)
140+
l.SetNotice("unable to open workspace in editor", styles.OutputLevelError)
140141
}
141142
case "s":
142143
if curWsCfg == nil {
143-
l.SetNotice("no workspace selected", styles.NoticeLevelError)
144+
l.SetNotice("no workspace selected", styles.OutputLevelError)
144145
break
145146
}
146147

147148
curCfg, err := filesystem.LoadConfig()
148149
if err != nil {
149150
l.ctx.Logger.Error(err, "unable to load user config")
150-
l.SetNotice("unable to load user config", styles.NoticeLevelError)
151+
l.SetNotice("unable to load user config", styles.OutputLevelError)
151152
break
152153
}
153154

154155
switch {
155156
case l.showNamespaces && curNs == withoutNamespaceLabel:
156157
curCfg.CurrentNamespace = ""
157158
case l.showNamespaces && curNs == allNamespacesLabel:
158-
l.SetNotice("no namespace selected", styles.NoticeLevelError)
159+
l.SetNotice("no namespace selected", styles.OutputLevelError)
159160
case l.showNamespaces && curNs != "":
160161
curCfg.CurrentNamespace = curNs
161162
case !l.showNamespaces && curWs == allWorkspacesLabel:
162-
l.SetNotice("no workspace selected", styles.NoticeLevelError)
163+
l.SetNotice("no workspace selected", styles.OutputLevelError)
163164
case !l.showNamespaces && curWs != "":
164165
if curWs != curWsCfg.AssignedName() {
165-
l.SetNotice("current workspace out of sync", styles.NoticeLevelError)
166+
l.SetNotice("current workspace out of sync", styles.OutputLevelError)
166167
break
167168
}
168169
curCfg.CurrentWorkspace = curWsCfg.AssignedName()
169170
}
170171

171172
if err := filesystem.WriteConfig(curCfg); err != nil {
172173
l.ctx.Logger.Error(err, "unable to write user config")
173-
l.SetNotice("unable to write user config", styles.NoticeLevelError)
174+
l.SetNotice("unable to write user config", styles.OutputLevelError)
174175
break
175176
}
176177

177178
l.ctx.Config.CurrentWorkspace = curCfg.CurrentWorkspace
178179
l.ctx.Config.CurrentNamespace = curCfg.CurrentNamespace
179-
l.SetNotice("context updated", styles.NoticeLevelInfo)
180+
l.SetNotice("context updated", styles.OutputLevelInfo)
180181
}
181182
}
182183

@@ -219,39 +220,38 @@ func (l *Library) updateExecPanes(msg tea.Msg) (viewport.Model, tea.Cmd) {
219220
}
220221
case "e":
221222
if curExec == nil {
222-
l.SetNotice("no executable selected", styles.NoticeLevelError)
223+
l.SetNotice("no executable selected", styles.OutputLevelError)
223224
break
224225
}
225226

226227
if err := common.OpenInEditor(curExec.FlowFilePath(), l.ctx.StdIn(), l.ctx.StdOut()); err != nil {
227228
l.ctx.Logger.Error(err, "unable to open executable in editor")
228-
l.SetNotice("unable to open executable in editor", styles.NoticeLevelError)
229+
l.SetNotice("unable to open executable in editor", styles.OutputLevelError)
229230
}
230231
case "c":
231232
if curExec == nil {
232-
l.SetNotice("no executable selected", styles.NoticeLevelError)
233+
l.SetNotice("no executable selected", styles.OutputLevelError)
233234
break
234235
}
235236

236237
if err := clipboard.WriteAll(curExec.Ref().String()); err != nil {
237238
l.ctx.Logger.Error(err, "unable to copy reference to clipboard")
238-
l.SetNotice("unable to copy reference to clipboard", styles.NoticeLevelError)
239+
l.SetNotice("unable to copy reference to clipboard", styles.OutputLevelError)
239240
} else {
240-
l.SetNotice("copied reference to clipboard", styles.NoticeLevelInfo)
241+
l.SetNotice("copied reference to clipboard", styles.OutputLevelInfo)
241242
}
242243
case "r":
243244
if curExec == nil {
244-
l.SetNotice("no executable selected", styles.NoticeLevelError)
245+
l.SetNotice("no executable selected", styles.OutputLevelError)
245246
break
246247
}
247248

248-
go func() {
249-
l.ctx.TUIContainer.Shutdown(func() {
250-
if err := l.cmdRunFunc(curExec.Ref().String()); err != nil {
251-
l.ctx.Logger.Fatalx("unable to execute command", "error", err)
252-
}
253-
})
254-
}()
249+
l.ctx.TUIContainer.Shutdown(func() {
250+
if err := l.cmdRunFunc(curExec.Ref().String()); err != nil {
251+
l.ctx.Logger.Fatalx("unable to execute command", "error", err)
252+
}
253+
})
254+
os.Exit(0) // This is necessary to prevent the app from hanging after the command is run
255255
case "f":
256256
if l.currentPane == 1 {
257257
break

internal/io/library/view.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ func (l *Library) View() string {
7676
return lipgloss.JoinVertical(lipgloss.Top, header, panes, footer)
7777
}
7878

79-
func (l *Library) SetNotice(notice string, level styles.NoticeLevel) {
79+
func (l *Library) SetNotice(notice string, level styles.OutputLevel) {
8080
if level == "" {
81-
level = styles.NoticeLevelInfo
81+
level = styles.OutputLevelInfo
8282
}
83-
l.noticeText = l.theme.RenderNotice(notice, level)
83+
l.noticeText = l.theme.RenderLevel(notice, level)
8484
}
8585

8686
func (l *Library) setSize() {

internal/io/secret/views.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func NewSecretView(
4444
return nil
4545
}
4646
LoadSecretListView(ctx, asPlainText)
47-
container.SetNotice("secret renamed", styles.NoticeLevelInfo)
47+
container.SetNotice("secret renamed", styles.OutputLevelInfo)
4848
return nil
4949
},
5050
},
@@ -73,7 +73,7 @@ func NewSecretView(
7373
return nil
7474
}
7575
LoadSecretListView(ctx, asPlainText)
76-
container.SetNotice("secret value updated", styles.NoticeLevelInfo)
76+
container.SetNotice("secret value updated", styles.OutputLevelInfo)
7777
return nil
7878
},
7979
},
@@ -85,7 +85,7 @@ func NewSecretView(
8585
return nil
8686
}
8787
LoadSecretListView(ctx, asPlainText)
88-
container.SetNotice("secret deleted", styles.NoticeLevelInfo)
88+
container.SetNotice("secret deleted", styles.OutputLevelInfo)
8989
return nil
9090
},
9191
},

internal/io/workspace/views.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func NewWorkspaceView(
5555
container.HandleError(err)
5656
}
5757
container.SetState(common.HeaderContextKey, fmt.Sprintf("%s/*", ws.AssignedName()))
58-
container.SetNotice("workspace updated", styles.NoticeLevelInfo)
58+
container.SetNotice("workspace updated", styles.OutputLevelInfo)
5959
return nil
6060
},
6161
},

0 commit comments

Comments
 (0)