Skip to content

Commit 25c9c7d

Browse files
committed
include to exported docs child commands
1 parent a65fdd9 commit 25c9c7d

File tree

8 files changed

+258
-47
lines changed

8 files changed

+258
-47
lines changed

docs.go

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package main
55

66
import (
77
"bytes"
8+
"errors"
89
"fmt"
910
"kool-dev/kool/commands"
1011
"kool-dev/kool/core/shell"
@@ -14,22 +15,17 @@ import (
1415
"regexp"
1516
"strings"
1617

18+
"github.com/spf13/cobra"
1719
"github.com/spf13/cobra/doc"
1820
)
1921

2022
func main() {
2123
var (
2224
err error
2325
koolOutput *bytes.Buffer
24-
cmdFile *os.File
2526
koolFile *os.File
2627
)
2728

28-
linkHandler := func(filename string) string {
29-
base := strings.TrimSuffix(filename, filepath.Ext(filename))
30-
return strings.ToLower(base)
31-
}
32-
3329
fmt.Println("Going to generate cobra docs in markdown...")
3430

3531
koolOutput = new(bytes.Buffer)
@@ -43,35 +39,12 @@ func main() {
4339
koolMarkdown := koolOutput.String()
4440

4541
for _, childCmd := range commands.RootCmd().Commands() {
46-
var cmdName string
47-
48-
if cmdName = strings.Replace(childCmd.CommandPath(), " ", "_", -1); cmdName == "kool_deploy" || cmdName == "kool_help" {
49-
continue
50-
}
51-
52-
newName := strings.Replace(childCmd.CommandPath(), " ", "-", -1)
53-
koolMarkdown = strings.Replace(koolMarkdown, cmdName, newName, -1)
54-
55-
cmdOutput := new(bytes.Buffer)
56-
57-
err = doc.GenMarkdownCustom(childCmd, cmdOutput, linkHandler)
58-
59-
if err != nil {
60-
log.Fatal(err)
61-
}
62-
63-
cmdFile, err = CreateFile(newName, "docs/4-Commands")
64-
65-
if err != nil {
66-
log.Fatal(err)
67-
}
68-
69-
defer cmdFile.Close()
70-
71-
_, err = cmdOutput.WriteTo(cmdFile)
72-
73-
if err != nil {
74-
log.Fatal(err)
42+
if err = exportCmdDocs(childCmd, &koolMarkdown); err != nil {
43+
if strings.HasPrefix(err.Error(), "skip") {
44+
log.Println(err)
45+
} else {
46+
log.Fatal(err)
47+
}
7548
}
7649
}
7750

@@ -106,3 +79,51 @@ func CreateFile(filename string, dir string) (file *os.File, err error) {
10679

10780
return
10881
}
82+
83+
func exportCmdDocs(childCmd *cobra.Command, koolMarkdown *string) (err error) {
84+
var (
85+
cmdName string
86+
cmdFile *os.File
87+
)
88+
89+
if cmdName = strings.Replace(childCmd.CommandPath(), " ", "_", -1); cmdName == "kool_help" {
90+
err = errors.New("skip kool_help")
91+
return
92+
}
93+
94+
newName := strings.Replace(childCmd.CommandPath(), " ", "-", -1)
95+
*koolMarkdown = strings.Replace(*koolMarkdown, cmdName, newName, -1)
96+
97+
cmdOutput := new(bytes.Buffer)
98+
99+
if err = doc.GenMarkdownCustom(childCmd, cmdOutput, linkHandler); err != nil {
100+
return
101+
}
102+
103+
if cmdFile, err = CreateFile(newName, "docs/4-Commands"); err != nil {
104+
return
105+
}
106+
107+
defer cmdFile.Close()
108+
109+
if _, err = cmdOutput.WriteTo(cmdFile); err != nil {
110+
return
111+
}
112+
113+
for _, subCmd := range childCmd.Commands() {
114+
if err = exportCmdDocs(subCmd, koolMarkdown); err != nil {
115+
if strings.HasPrefix(err.Error(), "skip") {
116+
log.Println(err)
117+
} else {
118+
return
119+
}
120+
}
121+
}
122+
123+
return
124+
}
125+
126+
func linkHandler(filename string) string {
127+
base := strings.TrimSuffix(filename, filepath.Ext(filename))
128+
return strings.ToLower(base)
129+
}

docs/3-Deploy-to-Kool-Cloud/1-Getting-Started.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1-
The Kool Cloud supports a wide range of features designed to suit your needs for deploying dockerized web applications. It supports features such as persisting folders across deployments, running daemons as extra containers, scheduling commands like cron jobs, adding hooks for before and after deployment, viewing running container logs, accessing the running container interactively, and much more.
1+
The [Kool Cloud](https://kool.dev/cloud) supports a wide range of features designed to suit your needs for deploying containerized web applications. It supports features such as **persisting folders** across deployments, running **daemons** as extra containers, scheduling commands like **cron jobs**, adding **hooks to run before or after** deployment, **viewing logs** of running container, accessing the running container **interactively**, and much more.
22

3-
The Deploy API was designed with the best developer experience in mind for deploying containers to the cloud. By leveraging your existing local environment structure in `docker-compose.yml` and adding a sane and intuitive configuration layer that will feel familiar from the first contact, our goal is to provide a best-in-class offering for cloud platform engineering. This platform allows you to leverage Kubernetes and orchestrate your web applications in the cloud without all the hassle.
3+
The Kool.dev Cloud API was designed with the best developer experience in mind for deploying containers to the cloud. By leveraging your existing local environment structure in `docker-compose.yml` and adding a sane and intuitive configuration layer that will feel familiar from the first sight, our goal is to provide a best-in-class offering for cloud platform engineering. This platform allows you to leverage Kubernetes and orchestrate your web applications in the cloud without all the hassle.
44

5-
**kool cloud** is a CLI suite of commands that allows you to configure, deploy, access, and tail logs from the applications to Kool Cloud via the Deploy API.
5+
> **Enterprise**: you can use Kool.dev Cloud to deploy workloads to your own cloud vendor to keep things compliant - [contact us](mailto:[email protected]) for **"Bring your Own Cloud"** offer.
6+
7+
**kool cloud** is the CLI suite of commands that allows you to configure, deploy, access, and tail logs from the applications to the cloud via the Kool.dev Cloud API.
68

79
## Deploy Docker Compose-based, containerized apps in just a few simple steps
810

9-
1. Sign up for Kool Cloud and get your access token.
10-
- Make sure your `.env` file contains two entries for configuring your deployment:
11-
- `KOOL_API_TOKEN` - the Deploy API access token you get from the kool.dev web panel.
12-
1. Configure your deployment with files straight in your application root folder
13-
- `kool.deploy.yml` - a "mirror" of your `docker-compose.yml` file, with extra pieces of data for your cloud deployment.
11+
1. [Sign up for Kool Cloud](https://kool.dev/register) and get your access token.
12+
- You can store your token in your `.env` file if you are using one:
13+
- `echo "KOOL_API_TOKEN=<my-token>" >> .env`
14+
- Or you can store your token in a real environment variable:
15+
- `export KOOL_API_TOKEN="<my token>"`
16+
1. Configure your deployment with files directly in your application root folder. For that you can use [`kool cloud setup`](TODO:cloud-setup) to help guide you creating the following files:
17+
- `kool.deploy.yml` - a "mirror" of your `docker-compose.yml` file, with extra pieces of data for customizing your cloud deployment.
1418
- `Dockerfile` - usually, you are going to need to build your app for deployment if you haven't already.
15-
- Make sure you set up the necessary environment variables for your app to run in the cloud.
19+
- Make sure you set up the necessary [environment variables](TODO:envs) for your app to run in the cloud.
1620
1. Deploy your application
17-
- Run `kool cloud deploy` - this will validate and deploy your application.
21+
- Run `kool cloud deploy --domain=<your domain>` - this will validate and deploy your application.
1822
- Wait for it to finish and then access the provided deployment URL!
1923
1. Doing more
2024
- **View logs**
2125
- `kool cloud logs` - you can check the logs of your deployed containers.
22-
- **Access cloud containers**
23-
- `kool cloud exec` - you can execute commands, including interactive TTY sessions, within your cloud-deployed containers.
26+
- **Access running containers (like SSH-ing in)**
27+
- `kool cloud exec` - you can execute commands, including interactive TTY sessions, within your cloud-deployed containers. For example: `kool cloud exec app bash` to open a bash in my running container in the cloud.
2428

2529
---
2630

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## kool cloud deploy
2+
3+
Deploy a local application to a Kool Cloud environment
4+
5+
```
6+
kool cloud deploy
7+
```
8+
9+
### Options
10+
11+
```
12+
--domain-extra stringArray List of extra domain aliases
13+
-h, --help help for deploy
14+
--timeout uint Timeout in minutes for waiting the deployment to finish
15+
--www-redirect Redirect www to non-www domain
16+
```
17+
18+
### Options inherited from parent commands
19+
20+
```
21+
--domain string Environment domain name to deploy to
22+
--token string Token to authenticate with Kool Cloud API
23+
--verbose Increases output verbosity
24+
-w, --working_dir string Changes the working directory for the command
25+
```
26+
27+
### SEE ALSO
28+
29+
* [kool cloud](kool_cloud) - Interact with Kool Cloud and manage your deployments.
30+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## kool cloud destroy
2+
3+
Destroy an environment deployed to Kool Cloud
4+
5+
```
6+
kool cloud destroy
7+
```
8+
9+
### Options
10+
11+
```
12+
-h, --help help for destroy
13+
```
14+
15+
### Options inherited from parent commands
16+
17+
```
18+
--domain string Environment domain name to deploy to
19+
--token string Token to authenticate with Kool Cloud API
20+
--verbose Increases output verbosity
21+
-w, --working_dir string Changes the working directory for the command
22+
```
23+
24+
### SEE ALSO
25+
26+
* [kool cloud](kool_cloud) - Interact with Kool Cloud and manage your deployments.
27+

docs/4-Commands/kool-cloud-exec.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## kool cloud exec
2+
3+
Execute a command inside a running service container deployed to Kool Cloud
4+
5+
### Synopsis
6+
7+
After deploying an application to Kool Cloud using 'kool deploy',
8+
execute a COMMAND inside the specified SERVICE container (similar to an SSH session).
9+
Must use a KOOL_API_TOKEN environment variable for authentication.
10+
11+
```
12+
kool cloud exec SERVICE [COMMAND] [--] [ARG...]
13+
```
14+
15+
### Options
16+
17+
```
18+
-c, --container string Container target. (default "default")
19+
-h, --help help for exec
20+
```
21+
22+
### Options inherited from parent commands
23+
24+
```
25+
--domain string Environment domain name to deploy to
26+
--token string Token to authenticate with Kool Cloud API
27+
--verbose Increases output verbosity
28+
-w, --working_dir string Changes the working directory for the command
29+
```
30+
31+
### SEE ALSO
32+
33+
* [kool cloud](kool_cloud) - Interact with Kool Cloud and manage your deployments.
34+

docs/4-Commands/kool-cloud-help.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## kool cloud help
2+
3+
Help about any command
4+
5+
### Synopsis
6+
7+
Help provides help for any command in the application.
8+
Simply type cloud help [path to command] for full details.
9+
10+
```
11+
kool cloud help [command] [flags]
12+
```
13+
14+
### Options
15+
16+
```
17+
-h, --help help for help
18+
```
19+
20+
### Options inherited from parent commands
21+
22+
```
23+
--domain string Environment domain name to deploy to
24+
--token string Token to authenticate with Kool Cloud API
25+
--verbose Increases output verbosity
26+
-w, --working_dir string Changes the working directory for the command
27+
```
28+
29+
### SEE ALSO
30+
31+
* [kool cloud](kool_cloud) - Interact with Kool Cloud and manage your deployments.
32+

docs/4-Commands/kool-cloud-logs.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## kool cloud logs
2+
3+
See the logs of running service container deployed to Kool Cloud
4+
5+
### Synopsis
6+
7+
After deploying an application to Kool Cloud using 'kool deploy',
8+
you can see the logs from the specified SERVICE container.
9+
Must use a KOOL_API_TOKEN environment variable for authentication.
10+
11+
```
12+
kool cloud logs [OPTIONS] SERVICE
13+
```
14+
15+
### Options
16+
17+
```
18+
-c, --container string Container target. (default "default")
19+
-f, --follow Follow log output.
20+
-h, --help help for logs
21+
-t, --tail int Number of lines to show from the end of the logs for each container. A value equal to 0 will show all lines. (default 25)
22+
```
23+
24+
### Options inherited from parent commands
25+
26+
```
27+
--domain string Environment domain name to deploy to
28+
--token string Token to authenticate with Kool Cloud API
29+
--verbose Increases output verbosity
30+
-w, --working_dir string Changes the working directory for the command
31+
```
32+
33+
### SEE ALSO
34+
35+
* [kool cloud](kool_cloud) - Interact with Kool Cloud and manage your deployments.
36+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## kool cloud setup
2+
3+
Set up local configuration files for deployment
4+
5+
```
6+
kool cloud setup
7+
```
8+
9+
### Options
10+
11+
```
12+
-h, --help help for setup
13+
```
14+
15+
### Options inherited from parent commands
16+
17+
```
18+
--domain string Environment domain name to deploy to
19+
--token string Token to authenticate with Kool Cloud API
20+
--verbose Increases output verbosity
21+
-w, --working_dir string Changes the working directory for the command
22+
```
23+
24+
### SEE ALSO
25+
26+
* [kool cloud](kool_cloud) - Interact with Kool Cloud and manage your deployments.
27+

0 commit comments

Comments
 (0)