You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-3Lines changed: 31 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Read the detailed [blogpost](https://zuplo.com/blog/2025/02/02/generate-cli-from
8
8
Go is a fantastic language to build CLI tooling, specially the ones for interacting with an API server. `<your tool>ctl` anyone?
9
9
But if you're tired of building bespoke CLIs everytime or think that the swagger codegen isn't just good enough or don't quite subscribe to the idea of codegen in general (like me!), look no further.
10
10
11
-
What if you can influence the CLI behaviour from the server? This enables you to bootstrap your [cobra](https://cobra.dev/) CLI tooling from an [OpenAPI](https://swagger.io/specification/) spec. Checkout [Wendy](https://bob-cd.github.io/cli/#wendy) as an example of a full CLI project made using climate.
11
+
What if you can influence the CLI behaviour from the server? This enables you to bootstrap your [cobra](https://cobra.dev/)or [urfave/cli](https://cli.urfave.org/)CLI tooling from an [OpenAPI](https://swagger.io/specification/) spec. Checkout [Wendy](https://bob-cd.github.io/cli/#wendy) as an example of a full CLI project made using climate.
12
12
13
13
## Getting started
14
14
@@ -53,25 +53,41 @@ Load the spec:
53
53
model, err:= climate.LoadFileV3("api.yaml") // or climate.LoadV3 with []byte
54
54
```
55
55
56
-
Define a cobra root command:
56
+
Define a root command:
57
57
58
58
```go
59
+
// Cobra
59
60
rootCmd:= &cobra.Command{
60
61
Use: "calc",
61
62
Short: "My Calc",
62
63
Long: "My Calc powered by OpenAPI",
63
64
}
65
+
66
+
// urfave/cli
67
+
rootCmd:= &cli.Command{
68
+
Name: "calc",
69
+
Description: "My Calc",
70
+
}
64
71
```
65
72
66
73
Define one or more handler functions of the following signature:
0 commit comments