Skip to content

Commit

Permalink
fix: squash a couple library view bugs and update docs (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
jahvon authored Sep 29, 2024
1 parent d5c1aed commit 4a1e5ec
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 70 deletions.
7 changes: 6 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ operations workflows.

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

## Features <!-- {docsify-ignore} -->
#### _Features_ <!-- {docsify-ignore} -->

- **Task Runner**: Easily define, manage, and run your tasks (called [executables](guide/executable.md)) from the command line.
- **Secret Vault**: Store sensitive secrets in a secure local [vault](guide/vault.md).
Expand All @@ -19,3 +19,8 @@ operations workflows.
- **Executable Organizer**: Group, reference, and search for executables by workspace, namespace, verbs, and tags.
- **Input Handler**: Pass values into executables with environment variables defined by secrets, command-line args, or interactive prompts.
- **Customizable TUI**: Personalize your [TUI experience](guide/interactive.md) with settings for log formatting, log archiving, and execution notifications, and more.

---

<p align="center"><img src="_media/demo.gif" width="1600"></p>

Binary file added docs/_media/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 22 additions & 11 deletions docs/demo.tape
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,43 @@
# Show Show the subsequent commands in the output

Output demo.gif
Require flow

# Setup
Set WindowBar Colorful
Set WindowBarSize 80
Set Shell "bash"
Set FontSize 32
Set Width 3200
Set FontSize 28
Set Width 3400
Set Height 1200
Set PlaybackSpeed 0.5
Set Padding 20

# Launch flow library
Hide
Env DISABLE_FLOW_INTERACTIVE "false"
Type "go build -o .bin/flow"
Enter
Type "alias flow=.bin/flow"
Enter
Type "clear"
Enter
Sleep 1s
Show
Type "flow library"
Sleep 2s
Enter

# Navigate to flow workspace / examples namespace
Sleep 5s
Down@1s
Space@1s
Sleep 5s
Down@2s
Space@2s
Down@1s 3
Sleep 3s

# Pick an executable to run
Right@1s
Sleep 2s
Down@3s 5
Sleep 3s
Down@2s 5
Sleep 3s

# Run the selected executable
Type "r"
Sleep 5s
Sleep 15s
11 changes: 11 additions & 0 deletions docs/docs.flow
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,14 @@ executables:
exec:
dir: //
cmd: docsify serve docs --open
- verb: start
name: recording
aliases: [vhs]
description: Record a demo of the Flow CLI and save it
tags: [vhs]
exec:
params:
- envKey: OUTPUT
text: docs/_media/demo.gif
dir: //
cmd: vhs -o $OUTPUT docs/demo.tape
17 changes: 16 additions & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A workspace can be created anywhere on your system but must be registered in ord
To create a new workspace, run the following command in the directory where you want the workspace to be created:

```shell
flow workspace create my-workspace .
flow workspace create my-workspace . --set
```

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

**Add another workspace**

If you're new to flow, try adding the `flow` workspace and explore the executables it contains.

```shell
git clone github.com/jahvon/flow
flow workspace create flow flow
```

When you have multiple workspaces, you can switch between them using a command like the following:

```shell
flow workspace set flow
```

**Running an executable**

Whenever you create, move, or delete executables and flow files, you will need to update the index of executables before running them.
Expand Down
2 changes: 1 addition & 1 deletion docs/types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ You can add the following comment to the top of your flow files to enable this:
# yaml-language-server: $schema=https://flowexec.io/schemas/flowfile_schema.json
```

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

Note: If using the flow file schema, you will need to make sure your IDE is configured to treat `*.flow` files as YAML files.
29 changes: 25 additions & 4 deletions examples/parallel.flow
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,28 @@ executables:
- verb: watch
name: parallel
parallel:
refs:
- run examples:with-output
- run examples:with-input
- run examples:from-file
execs:
- ref: run examples:with-output
- ref: run examples:with-input
- ref: run examples:from-file
- verb: restart
name: foo-sequence
parallel:
dir: f:tmp
execs:
- cmd: |
echo "Creating foo.txt" 1>&2
echo "foo bar baz" > foo.txt
- cmd: |
echo "Crunching the numbers..."
echo "Number of files in current directory: $(ls | wc -l)"
echo "Number of lines in this file: $(wc -l < foo.txt)"
echo "Number of words in this file: $(wc -w < foo.txt)"
- cmd: |
echo "Reviewing the data..."
sleep 2
cat foo.txt
sleep 2
echo "Deleting foo.txt" 1>&2
rm foo.txt
- ref: run examples:with-output
8 changes: 4 additions & 4 deletions examples/serial.flow
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ executables:
- verb: start
name: serial
serial:
refs:
- run examples:with-output
- run examples:with-input
- run examples:from-file
execs:
- ref: run examples:with-output
- ref: run examples:with-input
- ref: run examples:from-file
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/itchyny/gojq v0.12.16
github.com/jahvon/glamour v0.8.1-patch1
github.com/jahvon/open-golang v0.0.0-20240522004812-68511c3bc9ef
github.com/jahvon/tuikit v0.0.23
github.com/jahvon/tuikit v0.0.24
github.com/mattn/go-runewidth v0.0.16
github.com/onsi/ginkgo/v2 v2.20.2
github.com/onsi/gomega v1.34.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ github.com/jahvon/glamour v0.8.1-patch1 h1:ahDSYbmhdKtrl0q/QxyshaFXnhUUBmuDCyJk1
github.com/jahvon/glamour v0.8.1-patch1/go.mod h1:iGeJCQECnGJXk6X9D9UDUrtJ4hEUhYTIACdyNA2CAUk=
github.com/jahvon/open-golang v0.0.0-20240522004812-68511c3bc9ef h1:4PS/MNVT6Rsv15x5Rtwaw971e6kFvNUAf9nvUsZ5hcc=
github.com/jahvon/open-golang v0.0.0-20240522004812-68511c3bc9ef/go.mod h1:dUmuT5CN6osIeLSRtTPJOf0Yz+qAbcyU6omnCzI+ZfQ=
github.com/jahvon/tuikit v0.0.23 h1:mvgFU0yFHYPqdTr+kFYmA6qUD3drh40KGhiNoC6ZXMk=
github.com/jahvon/tuikit v0.0.23/go.mod h1:trQ4HzTqTwYkYinDSYIa/8XML9lxIuzYQpALJ0Y+p3w=
github.com/jahvon/tuikit v0.0.24 h1:5c7wcZg+Qonv9K+r0xVLNzpzTibuHXwZAyAeXrvOYwQ=
github.com/jahvon/tuikit v0.0.24/go.mod h1:trQ4HzTqTwYkYinDSYIa/8XML9lxIuzYQpALJ0Y+p3w=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down
4 changes: 2 additions & 2 deletions internal/io/executable/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewExecutableView(
if err := clipboard.WriteAll(exec.Ref().String()); err != nil {
container.HandleError(fmt.Errorf("unable to copy reference to clipboard: %w", err))
} else {
container.SetNotice("copied reference to clipboard", styles.NoticeLevelInfo)
container.SetNotice("copied reference to clipboard", styles.OutputLevelInfo)
}
return nil
},
Expand Down Expand Up @@ -112,7 +112,7 @@ func NewTemplateView(
if err := clipboard.WriteAll(template.Location()); err != nil {
container.HandleError(fmt.Errorf("unable to copy location to clipboard: %w", err))
} else {
container.SetNotice("copied location to clipboard", styles.NoticeLevelInfo)
container.SetNotice("copied location to clipboard", styles.OutputLevelInfo)
}
return nil
},
Expand Down
48 changes: 24 additions & 24 deletions internal/io/library/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package library

import (
"os"
"path/filepath"

"github.com/atotto/clipboard"
Expand Down Expand Up @@ -117,17 +118,17 @@ func (l *Library) updateWsPane(msg tea.Msg) (viewport.Model, tea.Cmd) {
}
case "o":
if curWsCfg == nil {
l.SetNotice("no workspace selected", styles.NoticeLevelError)
l.SetNotice("no workspace selected", styles.OutputLevelError)
break
}

if err := open.Open(curWsCfg.Location(), false); err != nil {
l.ctx.Logger.Error(err, "unable to open workspace")
l.SetNotice("unable to open workspace", styles.NoticeLevelError)
l.SetNotice("unable to open workspace", styles.OutputLevelError)
}
case "e":
if curWsCfg == nil {
l.SetNotice("no workspace selected", styles.NoticeLevelError)
l.SetNotice("no workspace selected", styles.OutputLevelError)
break
}

Expand All @@ -136,47 +137,47 @@ func (l *Library) updateWsPane(msg tea.Msg) (viewport.Model, tea.Cmd) {
l.ctx.StdIn(), l.ctx.StdOut(),
); err != nil {
l.ctx.Logger.Error(err, "unable to open workspace in editor")
l.SetNotice("unable to open workspace in editor", styles.NoticeLevelError)
l.SetNotice("unable to open workspace in editor", styles.OutputLevelError)
}
case "s":
if curWsCfg == nil {
l.SetNotice("no workspace selected", styles.NoticeLevelError)
l.SetNotice("no workspace selected", styles.OutputLevelError)
break
}

curCfg, err := filesystem.LoadConfig()
if err != nil {
l.ctx.Logger.Error(err, "unable to load user config")
l.SetNotice("unable to load user config", styles.NoticeLevelError)
l.SetNotice("unable to load user config", styles.OutputLevelError)
break
}

switch {
case l.showNamespaces && curNs == withoutNamespaceLabel:
curCfg.CurrentNamespace = ""
case l.showNamespaces && curNs == allNamespacesLabel:
l.SetNotice("no namespace selected", styles.NoticeLevelError)
l.SetNotice("no namespace selected", styles.OutputLevelError)
case l.showNamespaces && curNs != "":
curCfg.CurrentNamespace = curNs
case !l.showNamespaces && curWs == allWorkspacesLabel:
l.SetNotice("no workspace selected", styles.NoticeLevelError)
l.SetNotice("no workspace selected", styles.OutputLevelError)
case !l.showNamespaces && curWs != "":
if curWs != curWsCfg.AssignedName() {
l.SetNotice("current workspace out of sync", styles.NoticeLevelError)
l.SetNotice("current workspace out of sync", styles.OutputLevelError)
break
}
curCfg.CurrentWorkspace = curWsCfg.AssignedName()
}

if err := filesystem.WriteConfig(curCfg); err != nil {
l.ctx.Logger.Error(err, "unable to write user config")
l.SetNotice("unable to write user config", styles.NoticeLevelError)
l.SetNotice("unable to write user config", styles.OutputLevelError)
break
}

l.ctx.Config.CurrentWorkspace = curCfg.CurrentWorkspace
l.ctx.Config.CurrentNamespace = curCfg.CurrentNamespace
l.SetNotice("context updated", styles.NoticeLevelInfo)
l.SetNotice("context updated", styles.OutputLevelInfo)
}
}

Expand Down Expand Up @@ -219,39 +220,38 @@ func (l *Library) updateExecPanes(msg tea.Msg) (viewport.Model, tea.Cmd) {
}
case "e":
if curExec == nil {
l.SetNotice("no executable selected", styles.NoticeLevelError)
l.SetNotice("no executable selected", styles.OutputLevelError)
break
}

if err := common.OpenInEditor(curExec.FlowFilePath(), l.ctx.StdIn(), l.ctx.StdOut()); err != nil {
l.ctx.Logger.Error(err, "unable to open executable in editor")
l.SetNotice("unable to open executable in editor", styles.NoticeLevelError)
l.SetNotice("unable to open executable in editor", styles.OutputLevelError)
}
case "c":
if curExec == nil {
l.SetNotice("no executable selected", styles.NoticeLevelError)
l.SetNotice("no executable selected", styles.OutputLevelError)
break
}

if err := clipboard.WriteAll(curExec.Ref().String()); err != nil {
l.ctx.Logger.Error(err, "unable to copy reference to clipboard")
l.SetNotice("unable to copy reference to clipboard", styles.NoticeLevelError)
l.SetNotice("unable to copy reference to clipboard", styles.OutputLevelError)
} else {
l.SetNotice("copied reference to clipboard", styles.NoticeLevelInfo)
l.SetNotice("copied reference to clipboard", styles.OutputLevelInfo)
}
case "r":
if curExec == nil {
l.SetNotice("no executable selected", styles.NoticeLevelError)
l.SetNotice("no executable selected", styles.OutputLevelError)
break
}

go func() {
l.ctx.TUIContainer.Shutdown(func() {
if err := l.cmdRunFunc(curExec.Ref().String()); err != nil {
l.ctx.Logger.Fatalx("unable to execute command", "error", err)
}
})
}()
l.ctx.TUIContainer.Shutdown(func() {
if err := l.cmdRunFunc(curExec.Ref().String()); err != nil {
l.ctx.Logger.Fatalx("unable to execute command", "error", err)
}
})
os.Exit(0) // This is necessary to prevent the app from hanging after the command is run
case "f":
if l.currentPane == 1 {
break
Expand Down
6 changes: 3 additions & 3 deletions internal/io/library/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ func (l *Library) View() string {
return lipgloss.JoinVertical(lipgloss.Top, header, panes, footer)
}

func (l *Library) SetNotice(notice string, level styles.NoticeLevel) {
func (l *Library) SetNotice(notice string, level styles.OutputLevel) {
if level == "" {
level = styles.NoticeLevelInfo
level = styles.OutputLevelInfo
}
l.noticeText = l.theme.RenderNotice(notice, level)
l.noticeText = l.theme.RenderLevel(notice, level)
}

func (l *Library) setSize() {
Expand Down
6 changes: 3 additions & 3 deletions internal/io/secret/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewSecretView(
return nil
}
LoadSecretListView(ctx, asPlainText)
container.SetNotice("secret renamed", styles.NoticeLevelInfo)
container.SetNotice("secret renamed", styles.OutputLevelInfo)
return nil
},
},
Expand Down Expand Up @@ -73,7 +73,7 @@ func NewSecretView(
return nil
}
LoadSecretListView(ctx, asPlainText)
container.SetNotice("secret value updated", styles.NoticeLevelInfo)
container.SetNotice("secret value updated", styles.OutputLevelInfo)
return nil
},
},
Expand All @@ -85,7 +85,7 @@ func NewSecretView(
return nil
}
LoadSecretListView(ctx, asPlainText)
container.SetNotice("secret deleted", styles.NoticeLevelInfo)
container.SetNotice("secret deleted", styles.OutputLevelInfo)
return nil
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/io/workspace/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewWorkspaceView(
container.HandleError(err)
}
container.SetState(common.HeaderContextKey, fmt.Sprintf("%s/*", ws.AssignedName()))
container.SetNotice("workspace updated", styles.NoticeLevelInfo)
container.SetNotice("workspace updated", styles.OutputLevelInfo)
return nil
},
},
Expand Down
Loading

0 comments on commit 4a1e5ec

Please sign in to comment.