Skip to content

Commit dd944b1

Browse files
authored
Add docs gen and cleanup readme (#57)
1 parent 2dd748e commit dd944b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1077
-112
lines changed

README.md

+46-43
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,22 @@
1-
# flow - Local, CLI Workflow Manager
1+
# flow - One CLI to manage all your development workflows and systems
22

3-
## Configuration and Workflow Definition Files
3+
[![Go Report Card](https://goreportcard.com/badge/github.com/jahvon/flow)](https://goreportcard.com/report/github.com/jahvon/flow)
4+
[![Go Reference](https://pkg.go.dev/badge/github.com/jahvon/flow.svg)](https://pkg.go.dev/github.com/jahvon/flow)
5+
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/jahvon/flow)](
46

5-
`flow` uses a configuration file to define the workspaces and workflows that it manages.
6-
The location for this flow configuration file is `~/.flow/config.yaml`. Below is an example of a flow configuration file.
7+
## Getting Started
78

8-
```yaml
9-
currentWorkspace: workspace1
10-
workspaces:
11-
workspace1: /path/to/workspace1
12-
workspace2: /path/to/workspace2
13-
```
14-
15-
Workflows can be defined anywhere within a workspace's directory with the `.flow` file extension.
16-
Below is an example of a workflow definition file.
17-
18-
```yaml
19-
namespace: ns
20-
tags:
21-
- example
22-
executables:
23-
- type: open
24-
name: config
25-
tags:
26-
- config
27-
description: open flow config in vscode
28-
spec:
29-
uri: .flow
30-
application: Visual Studio Code
31-
```
32-
33-
Running `flow open ns:config` will run the above workflow.
34-
35-
## CLI Usage
36-
37-
See [flow CLI documentation](docs/cli/flow.md) for more information.
38-
39-
**Autocompletion**
40-
41-
Example autocompletion setup script: `flow completion zsh > ~/.oh-my-zsh/completions/_flow`
42-
43-
## Install
9+
### Installation
4410

4511
You can install the pre-compiled binary or compile from source.
4612

47-
### via Go Install
13+
#### via Go Install
4814

4915
```bash
5016
go install github.com/jahvon/flow@latest
5117
```
5218

53-
### via GitHub Releases
19+
#### via GitHub Releases
5420

5521
Download the pre-compiled binaries from the [release page](https://github.com/jahvon/flow/releases) page and copy them to the desired location.
5622

@@ -64,11 +30,48 @@ $ sudo tar xvf ${TAR_FILE} flow -C /usr/local/bin
6430
$ rm -f ${TAR_FILE}
6531
```
6632

67-
### via Source
33+
#### via Source
6834

6935
```bash
7036
$ git clone github.com/jahvon/flow
7137
$ cd flow
7238
$ go generate ./...
7339
$ go install
7440
```
41+
42+
### Setting up a Workspace
43+
44+
A Workspace is a directory that contains workflows and configuration files for `flow` to manage.
45+
A workspace can be created anywhere on your system but must be registered in the User Config file in order to
46+
have executables discovered by `flow`.
47+
48+
To create a new workspace:
49+
50+
```bash
51+
flow init workspace <name> <path>
52+
```
53+
54+
This command will register the Workspace and create the root config file for you.
55+
For more information on Workspaces and it's config, see [Workspaces](docs/config/workspace_config.md).
56+
57+
### Defining Executables
58+
59+
Executables are the core of `flow`. They are the workflows that `flow` will execute when running a workflow.
60+
Each executable is driven by its definition within an executable definition file (`*.flow` file). There are
61+
several types of executables that can be defined.
62+
For more information on Executables and it's config, see [Executables](docs/config/executables.md).
63+
64+
65+
### Running and managing workflows
66+
67+
The main command for running workflows is `flow exec`. This command will execute the workflow with the provided
68+
executable ID. `exec` can be replaced with any verb but should match the verb defined in the executable's definition or
69+
an alias of the verb.
70+
71+
As you make changes to executables on your system, you can run `flow sync` to trigger a re-index of your executables.
72+
73+
See [flow CLI documentation](docs/cli/flow.md) for more information on all available commands.
74+
75+
**Autocompletion**
76+
77+
Example autocompletion setup script: `flow completion zsh > ~/.oh-my-zsh/completions/_flow`

cmd/common.go

+1
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,6 @@ func exitApp(_ *cobra.Command, _ []string) {
136136
}
137137

138138
func GenerateMarkdownTree(dir string) error {
139+
rootCmd.DisableAutoGenTag = true
139140
return doc.GenMarkdownTree(rootCmd, dir)
140141
}

cmd/exec.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ var execCmd = &cobra.Command{
2929
Short: "Execute a flow by ID.",
3030
Long: "Execute a flow where <executable-id> is the target executable's ID in the form of 'ws/ns:name'.\n" +
3131
"The flow subcommand used should match the target executable's verb or one of its aliases.\n\n" +
32-
"See " + io.DocsURL("executable-verbs") + "for more information on executable verbs." +
33-
"See " + io.DocsURL("executable-ids") + "for more information on executable IDs.",
32+
"See " + io.ConfigDocsURL("executables", "Verb") + "for more information on executable verbs." +
33+
"See " + io.ConfigDocsURL("executables", "Ref") + "for more information on executable IDs.",
3434
Args: cobra.ExactArgs(1),
3535
PreRun: func(cmd *cobra.Command, args []string) {
3636
startApp(cmd, args)

cmd/get.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ var executableGetCmd = &cobra.Command{
9595
Short: "Print an executable flow by reference.",
9696
Long: "Print an executable by the executable's verb and ID.\nThe target executable's ID should be in the " +
9797
"form of 'ws/ns:name' and the verb should match the target executable's verb or one of its aliases.\n\n" +
98-
"See" + io.DocsURL("executable-verbs") + "for more information on executable verbs." +
99-
"See" + io.DocsURL("executable-ids") + "for more information on executable IDs.",
98+
"See" + io.ConfigDocsURL("executables", "Verb") + "for more information on executable verbs." +
99+
"See" + io.ConfigDocsURL("executable", "Ref") + "for more information on executable IDs.",
100100
Args: cobra.ExactArgs(2),
101101
PreRun: startApp,
102102
PostRun: waitForExit,

config/common.go

+20
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ const (
1414
LaunchGroupID = "launch"
1515
)
1616

17+
// +docsgen:verb
18+
// Keywords that describe the action an executable performs.
19+
// While executables are configured with a single verb, the verb can be aliased to related verbs.
20+
// For example, the `exec` verb can replaced with "run" or "start" when referencing an executable.
21+
// This allows users to use the verb that best describes the action they are performing.
22+
//
23+
// **Activation verbs**: `exec`, `run`, `start`, `install`, `setup`
24+
// **Deactivation verbs**: `delete`, `remove`, `uninstall`, `teardown`, `destroy`
25+
// **Launch verbs**: `open`, `launch`, `edit`, `show`, `view`, `render`, `process`, `transform`, `generate`
1726
type Verb string
1827

1928
var (
@@ -116,6 +125,9 @@ func (v VisibilityType) IsHidden() bool {
116125
return v == VisibilityHidden
117126
}
118127

128+
// +docsgen:tags
129+
// A list of tags.
130+
// Tags can be used with list commands to filter returned data.
119131
type Tags []string
120132

121133
func (t Tags) String() string {
@@ -173,6 +185,14 @@ func (a Aliases) HasAlias(alias string) bool {
173185
return false
174186
}
175187

188+
// +docsgen:ref
189+
// A reference to an executable.
190+
// The format is `<verb> <workspace>/<namespace>:<executable name>`.
191+
// For example, `exec ws/ns:my-flow`.
192+
//
193+
// The workspace and namespace are optional.
194+
// If the workspace is not specified, the current workspace will be used.
195+
// If the namespace is not specified, the current namespace will be used.
176196
type Ref string
177197

178198
func NewRef(id string, verb Verb) Ref {

config/executable_definitions.go

+17-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,23 @@ import (
55
)
66

77
type ExecutableDefinition struct {
8-
Namespace string `yaml:"namespace"`
9-
Tags Tags `yaml:"tags"`
10-
Visibility VisibilityType `yaml:"visibility"`
8+
// +docsgen:namespace
9+
// The namespace of the executable definition. This is used to group executables together.
10+
// If not set, the executables in the definition will be grouped into the root (*) namespace.
11+
// Namespaces can be reused across multiple definitions.
12+
Namespace string `yaml:"namespace"`
13+
Tags Tags `yaml:"tags"`
14+
// +docsgen:visibility
15+
// The visibility of the executables to Flow.
16+
// If not set, the visibility will default to `public`.
17+
//
18+
// `public` executables can be executed and listed from anywhere.
19+
// `private` executables can be executed and listed only within their own workspace.
20+
// `internal` executables can be executed within their own workspace but are not listed.
21+
// `hidden` executables cannot be executed or listed.
22+
Visibility VisibilityType `yaml:"visibility"`
23+
// +docsgen:executables
24+
// A list of executables to be defined in the executable definition.
1125
Executables ExecutableList `yaml:"executables"`
1226

1327
workspaceName, workspacePath, definitionPath string

config/executables.go

+38-13
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ import (
1818
const tmpdir = "f:tmp"
1919

2020
type DirectoryScopedExecutable struct {
21+
// +docsgen:dir
22+
// The directory to execute the command in.
23+
// If unset, the directory of the executable definition will be used.
24+
// If set to `f:tmp`, a temporary directory will be created for the process.
25+
// If prefixed with `./`, the path will be relative to the current working directory.
26+
// If prefixed with `//`, the path will be relative to the workspace root.
27+
// Environment variables in the path will be expended at runtime.
2128
Directory string `yaml:"dir"`
2229
}
2330

@@ -41,6 +48,8 @@ func (e *DirectoryScopedExecutable) ExpandDirectory(
4148
}
4249

4350
type ParameterizedExecutable struct {
51+
// +docsgen:params
52+
// List of parameters to pass to the executable.
4453
Parameters ParameterList `yaml:"params"`
4554
}
4655

@@ -104,6 +113,8 @@ type RenderExecutableType struct {
104113
type SerialExecutableType struct {
105114
ParameterizedExecutable `yaml:",inline"`
106115

116+
// +docsgen:refs
117+
// List of executables references
107118
ExecutableRefs []Ref `yaml:"refs"`
108119
FailFast bool `yaml:"failFast"`
109120
}
@@ -117,23 +128,37 @@ type ParallelExecutableType struct {
117128
}
118129

119130
type ExecutableTypeSpec struct {
120-
Exec *ExecExecutableType `yaml:"exec,omitempty"`
121-
Launch *LaunchExecutableType `yaml:"launch,omitempty"`
122-
Request *RequestExecutableType `yaml:"request,omitempty"`
123-
Render *RenderExecutableType `yaml:"render,omitempty"`
124-
Serial *SerialExecutableType `yaml:"serial,omitempty"`
131+
// +docsgen:exec
132+
// Standard executable type. Runs a command/file in a subprocess.
133+
Exec *ExecExecutableType `yaml:"exec,omitempty"`
134+
// +docsgen:launch
135+
// Launches an application or opens a URI.
136+
Launch *LaunchExecutableType `yaml:"launch,omitempty"`
137+
// +docsgen:request
138+
// Makes an HTTP request.
139+
Request *RequestExecutableType `yaml:"request,omitempty"`
140+
// +docsgen:render
141+
// Renders a Markdown template with provided data. Requires the Interactive UI.
142+
Render *RenderExecutableType `yaml:"render,omitempty"`
143+
// +docsgen:serial
144+
// Runs a list of executables in serial.
145+
Serial *SerialExecutableType `yaml:"serial,omitempty"`
146+
// +docsgen:parallel
147+
// Runs a list of executables in parallel.
125148
Parallel *ParallelExecutableType `yaml:"parallel,omitempty"`
126149
}
127150

128151
type Executable struct {
129-
Verb Verb `yaml:"verb"`
130-
Name string `yaml:"name"`
131-
Aliases []string `yaml:"aliases"`
132-
Tags Tags `yaml:"tags"`
133-
Description string `yaml:"description"`
134-
Visibility VisibilityType `yaml:"visibility"`
135-
Timeout time.Duration `yaml:"timeout"`
136-
Type *ExecutableTypeSpec `yaml:"type"`
152+
Verb Verb `yaml:"verb"`
153+
Name string `yaml:"name"`
154+
Aliases []string `yaml:"aliases"`
155+
Tags Tags `yaml:"tags"`
156+
Description string `yaml:"description"`
157+
Visibility VisibilityType `yaml:"visibility"`
158+
Timeout time.Duration `yaml:"timeout"`
159+
// +docsgen:type
160+
// The type of executable. Only one type can be set.
161+
Type *ExecutableTypeSpec `yaml:"type"`
137162

138163
workspace, namespace, workspacePath, definitionPath string
139164
}

config/parameter.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,22 @@ import (
99
"github.com/jahvon/flow/internal/utils"
1010
)
1111

12+
// +docsgen:param
13+
// A parameter is a value that can be passed to an executable and all of its sub-executables.
14+
// Only one of `text`, `secretRef`, or `prompt` must be set. Specifying more than one will result in an error.
1215
type Parameter struct {
13-
// Only one of text, secretRef, or prompt should be set.
14-
Text string `yaml:"text"`
15-
Prompt string `yaml:"prompt"`
16+
// +docsgen:text
17+
// A static value to be passed to the executable.
18+
Text string `yaml:"text"`
19+
// +docsgen:secretRef
20+
// A reference to a secret to be passed to the executable.
21+
Prompt string `yaml:"prompt"`
22+
// +docsgen:prompt
23+
// A prompt to be displayed to the user to collect a value to be passed to the executable.
1624
SecretRef string `yaml:"secretRef"`
1725

26+
// +docsgen:envKey
27+
// The name of the environment variable that will be set with the value of the parameter.
1828
EnvKey string `yaml:"envKey"`
1929
}
2030

config/user_config.go

+20-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,28 @@ import (
88
)
99

1010
type InteractiveConfig struct {
11-
Enabled bool `json:"enabled" yaml:"enabled"`
12-
NotifyOnCompletion bool `json:"notify" yaml:"notify"`
13-
SoundOnCompletion bool `json:"sound" yaml:"sound"`
11+
Enabled bool `json:"enabled" yaml:"enabled"`
12+
// +docsgen:notify
13+
// Whether to send a desktop notification when a command completes.
14+
NotifyOnCompletion bool `json:"notify" yaml:"notify"`
15+
// +docsgen:sound
16+
// Whether to play a sound when a command completes.
17+
SoundOnCompletion bool `json:"sound" yaml:"sound"`
1418
}
19+
1520
type UserConfig struct {
16-
Workspaces map[string]string `json:"workspaces" yaml:"workspaces"`
17-
CurrentWorkspace string `json:"currentWorkspace" yaml:"currentWorkspace"`
18-
CurrentNamespace string `json:"currentNamespace" yaml:"currentNamespace"`
19-
Interactive *InteractiveConfig `json:"interactive" yaml:"interactive"`
21+
// +docsgen:workspaces
22+
// Map of workspace names to their paths.
23+
Workspaces map[string]string `json:"workspaces" yaml:"workspaces"`
24+
// +docsgen:currentWorkspace
25+
// The name of the current workspace. This should match a key in the `workspaces` map.
26+
CurrentWorkspace string `json:"currentWorkspace" yaml:"currentWorkspace"`
27+
// +docsgen:currentNamespace
28+
// The name of the current namespace. This is not required to be set.
29+
CurrentNamespace string `json:"currentNamespace" yaml:"currentNamespace"`
30+
// +docsgen:interactive
31+
// Configurations for the interactive UI.
32+
Interactive *InteractiveConfig `json:"interactive" yaml:"interactive"`
2033
}
2134

2235
func (c *UserConfig) Validate() error {

config/workspace_config.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
)
1212

1313
type WorkspaceConfig struct {
14+
// +docsgen:displayName
15+
// The display name of the workspace. This is used in the interactive UI.
1416
DisplayName string `json:"displayName" yaml:"displayName"`
1517
Description string `json:"description,omitempty" yaml:"description,omitempty"`
1618
Tags Tags `json:"tags,omitempty" yaml:"tags,omitempty"`
@@ -24,12 +26,19 @@ type WorkspaceConfig struct {
2426
type WorkspaceConfigList []WorkspaceConfig
2527

2628
type GitConfig struct {
27-
Enabled bool `json:"enabled" yaml:"enabled"`
29+
Enabled bool `json:"enabled" yaml:"enabled"`
30+
31+
// +docsgen:pullOnSync
32+
// Whether to pull the latest changes from the remote when syncing.
2833
PullOnSync bool `json:"pullOnSync,omitempty" yaml:"pullOnSync,omitempty"`
2934
}
3035

3136
type ExecutableLocationConfig struct {
37+
// +docsgen:included
38+
// A list of directories to include in the executable search.
3239
Included []string `json:"included,omitempty" yaml:"included,omitempty"`
40+
// +docsgen:excluded
41+
// A list of directories to exclude from the executable search.
3342
Excluded []string `json:"excluded,omitempty" yaml:"excluded,omitempty"`
3443
}
3544

0 commit comments

Comments
 (0)