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
feat(docs): Enhance project creation guide and add detailed API definitions
- Updated the "Creating Your First Project" guide with a comprehensive step-by-step process for setting up a new application using the Sphere framework.
- Expanded the API Definitions documentation to include detailed examples, key components, URL path mapping, and best practices for defining HTTP interfaces using Protobuf.
- Introduced a new "Logging" guide that outlines the logging system in Sphere, including configuration, usage, log levels, and best practices for effective logging.
- Added error handling documentation with examples of generating typed errors from Protobuf enums, including installation and configuration instructions for `protoc-gen-sphere-errors`.
- Updated the guides index to include a link to the new Logging guide.
Sphere CLI (`sphere-cli`) is a command-line tool designed to streamline the development of [Sphere](https://github.com/go-sphere/sphere) projects. It helps you create new projects, generate service code, manage Protobuf definitions, and perform other common development tasks.
7
+
8
+
## Installation
9
+
10
+
To install `sphere-cli`, ensure you have Go installed and run the following command:
11
+
12
+
```shell
13
+
go install github.com/go-sphere/sphere-cli@latest
14
+
```
15
+
16
+
## Usage
17
+
18
+
The general syntax for `sphere-cli` is:
19
+
20
+
```shell
21
+
sphere-cli [command] [flags]
22
+
```
23
+
24
+
For detailed information on any command, you can use the `--help` flag:
25
+
26
+
```shell
27
+
sphere-cli [command] --help
28
+
```
29
+
30
+
## Commands
31
+
32
+
Here is an overview of the available commands.
33
+
34
+
### `create`
35
+
36
+
Initializes a new Sphere project with a default template.
This command creates a new project directory with the [sphere-layout](https://github.com/go-sphere/sphere-layout) template, including:
53
+
- Makefile for build automation
54
+
- buf configuration for protobuf management
55
+
- Standard directory structure
56
+
- Example configurations
57
+
58
+
### `entproto`
59
+
60
+
Converts Ent schemas into Protobuf (`.proto`) definitions. This command reads your Ent schema files and generates corresponding `.proto` files.
61
+
62
+
**Usage:**
63
+
```shell
64
+
sphere-cli entproto [flags]
65
+
```
66
+
67
+
**Flags:**
68
+
-`--path string`: Path to the Ent schema directory (default: `./schema`).
69
+
-`--proto string`: Output directory for the generated `.proto` files (default: `./proto`).
70
+
-`--all_fields_required`: Treat all fields as required, ignoring `Optional()` (default: `true`).
71
+
-`--auto_annotation`: Automatically add `@entproto` annotations to the schema (default: `true`).
72
+
-`--enum_raw_type`: Use `string` as the type for enums in Protobuf (default: `true`).
73
+
-`--skip_unsupported`: Skip fields with types that are not supported (default: `true`).
74
+
-`--time_proto_type string`: Protobuf type to use for `time.Time` fields. Options: `int64`, `string`, `google.protobuf.Timestamp` (default: `int64`).
75
+
-`--uuid_proto_type string`: Protobuf type to use for `uuid.UUID` fields. Options: `string`, `bytes` (default: `string`).
76
+
-`--unsupported_proto_type string`: Protobuf type to use for unsupported fields. Options: `google.protobuf.Any`, `google.protobuf.Struct`, `bytes` (default: `google.protobuf.Any`).
Generates service code, including both Protobuf definitions and Go service implementations.
87
+
88
+
This command has two subcommands: `proto` and `golang`.
89
+
90
+
#### `service proto`
91
+
92
+
Generates a `.proto` file for a new service.
93
+
94
+
**Usage:**
95
+
```shell
96
+
sphere-cli service proto --name <service-name> [--package <package-name>]
97
+
```
98
+
99
+
**Flags:**
100
+
-`--name string`: (Required) The name of the service.
101
+
-`--package string`: The package name for the generated `.proto` file (default: `dash.v1`).
102
+
103
+
**Example:**
104
+
```shell
105
+
sphere-cli service proto --name UserService --package api.v1
106
+
```
107
+
108
+
#### `service golang`
109
+
110
+
Generates the Go implementation for a service from its definition.
111
+
112
+
**Usage:**
113
+
```shell
114
+
sphere-cli service golang --name <service-name> [--package <package-name>] [--mod <go-module-path>]
115
+
```
116
+
117
+
**Flags:**
118
+
-`--name string`: (Required) The name of the service.
119
+
-`--package string`: The package name for the generated Go code (default: `dash.v1`).
120
+
-`--mod string`: The Go module path for the generated code (default: `github.com/go-sphere/sphere-layout`).
121
+
122
+
**Example:**
123
+
```shell
124
+
sphere-cli service golang --name UserService --package api.v1 --mod github.com/myorg/myproject
125
+
```
126
+
127
+
### `retags` (Deprecated)
128
+
129
+
> **Note**: This command is deprecated. Use [`protoc-gen-sphere-binding`](../generators/protoc-gen-sphere-binding) instead.
130
+
131
+
The `retags` command was used to inject struct tags into generated protobuf Go files, but this functionality has been moved to the more robust `protoc-gen-sphere-binding` plugin.
132
+
133
+
### `rename`
134
+
135
+
Renames the Go module path across the entire repository. This is useful when you need to change the module path after creating a project.
0 commit comments