From 8f0fe731664104aa4a60229e253a3730d5a32c08 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki Date: Sun, 29 Nov 2020 10:37:37 +0200 Subject: [PATCH] doc: rename cmd entc to ent --- README.md | 2 +- doc/md/code-gen.md | 44 +++++++++++++++++++-------------------- doc/md/crud.md | 2 +- doc/md/getting-started.md | 16 +++++++------- doc/md/privacy.md | 2 +- doc/md/schema-def.md | 2 +- doc/md/schema-fields.md | 2 +- doc/md/templates.md | 4 ++-- doc/md/traversals.md | 2 +- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index ffee6f0ef8..3ebd332b8e 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ with large data-models. ## Quick Installation ```console -go get github.com/facebook/ent/cmd/entc +go get github.com/facebook/ent/cmd/ent ``` For proper installation using [Go modules], visit [entgo.io website][entgo instal]. diff --git a/doc/md/code-gen.md b/doc/md/code-gen.md index 508464b14b..ad5b3c25a7 100755 --- a/doc/md/code-gen.md +++ b/doc/md/code-gen.md @@ -5,19 +5,19 @@ title: Introduction ## Installation -`ent` comes with a codegen tool called `entc`. In order to install -`entc` run the following command: +The project comes with a codegen tool called `ent`. In order to install +`ent` run the following command: ```bash -go get github.com/facebook/ent/cmd/entc +go get github.com/facebook/ent/cmd/ent ``` ## Initialize A New Schema -In order to generate one or more schema templates, run `entc init` as follows: +In order to generate one or more schema templates, run `ent init` as follows: ```bash -entc init User Pet +go run github.com/facebook/ent/cmd/ent init User Pet ``` `init` will create the 2 schemas (`user.go` and `pet.go`) under the `ent/schema` directory. @@ -27,7 +27,7 @@ is to have an `ent` directory under the root directory of the project. ## Generate Assets After adding a few [fields](schema-fields.md) and [edges](schema-edges.md), you want to generate -the assets for working with your entities. Run `entc generate` from the root directory of the project, +the assets for working with your entities. Run `ent generate` from the root directory of the project, or use `go generate`: @@ -45,11 +45,11 @@ The `generate` command generates the following assets for the schemas: ## Version Compatibility Between `entc` And `ent` -When working with `entc` in a project, you want to make sure that the version being -used by `entc` is **identical** to the `ent` version used by your project. +When working with `ent` CLI in a project, you want to make sure the version being +used by the CLI is **identical** to the `ent` version used by your project. One of the options for achieving this is asking `go generate` to use the version -mentioned in the `go.mod` file when running `entc`. If your project does not use +mentioned in the `go.mod` file when running `ent`. If your project does not use [Go modules](https://github.com/golang/go/wiki/Modules#quick-start), setup one as follows: ```console @@ -59,7 +59,7 @@ go mod init And then, re-run the following command in order to add `ent` to your `go.mod` file: ```console -go get github.com/facebook/ent/cmd/entc +go get github.com/facebook/ent/cmd/ent ``` Add a `generate.go` file to your project under `/ent`: @@ -67,25 +67,25 @@ Add a `generate.go` file to your project under `/ent`: ```go package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate ./schema ``` Finally, you can run `go generate ./ent` from the root directory of your project -in order to run `entc` code generation on your project schemas. +in order to run `ent` code generation on your project schemas. ## Code Generation Options -For more info about codegen options, run `entc generate -h`: +For more info about codegen options, run `ent generate -h`: ```console generate go code for the schema directory Usage: - entc generate [flags] path + ent generate [flags] path Examples: - entc generate ./ent/schema - entc generate github.com/a8m/x + ent generate ./ent/schema + ent generate github.com/a8m/x Flags: --feature strings extend codegen with additional features @@ -99,24 +99,24 @@ Flags: ## Storage Options -`entc` can generate assets for both SQL and Gremlin dialect. The default dialect is SQL. +`ent` can generate assets for both SQL and Gremlin dialect. The default dialect is SQL. ## External Templates -`entc` accepts external Go templates to execute. If the template name is already defined by -`entc`, it will override the existing one. Otherwise, it will write the execution output to +`ent` accepts external Go templates to execute. If the template name already defined by +`ent`, it will override the existing one. Otherwise, it will write the execution output to a file with the same name as the template. The flag format supports `file`, `dir` and `glob` as follows: ```console -entc generate --template --template glob="path/to/*.tmpl" ./ent/schema +go run github.com/facebook/ent/cmd/ent generate --template --template glob="path/to/*.tmpl" ./ent/schema ``` More information and examples can be found in the [external templates doc](templates.md). ## Use `entc` As A Package -Another option for running `entc` is to use it as a package as follows: +Another option for running `ent` CLI is to use it as a package as follows: ```go package main @@ -148,7 +148,7 @@ The full example exists in [GitHub](https://github.com/facebook/ent/tree/master/ In order to get a description of your graph schema, run: ```bash -entc describe ./ent/schema +go run github.com/facebook/ent/cmd/ent describe ./ent/schema ``` An example for the output is as follows: diff --git a/doc/md/crud.md b/doc/md/crud.md index 9541bd9f13..2d66ed9c41 100755 --- a/doc/md/crud.md +++ b/doc/md/crud.md @@ -3,7 +3,7 @@ id: crud title: CRUD API --- -As mentioned in the [introduction](code-gen.md) section, running `entc` on the schemas, +As mentioned in the [introduction](code-gen.md) section, running `ent` on the schemas, will generate the following assets: - `Client` and `Tx` objects used for interacting with the graph. diff --git a/doc/md/getting-started.md b/doc/md/getting-started.md index c4aef92e03..d5137c1723 100755 --- a/doc/md/getting-started.md +++ b/doc/md/getting-started.md @@ -20,11 +20,11 @@ and maintain applications with large data-models and sticks with the following p ## Installation ```console -go get github.com/facebook/ent/cmd/entc +go get github.com/facebook/ent/cmd/ent ``` -After installing `entc` (the code generator for `ent`), you should have it in your `PATH`. -If you don't find it your path, you can also run: `go run github.com/facebook/ent/cmd/entc ` +After installing `ent` codegen tool, you should have it in your `PATH`. +If you don't find it your path, you can also run: `go run github.com/facebook/ent/cmd/ent ` ## Setup A Go Environment @@ -40,7 +40,7 @@ go mod init Go to the root directory of your project, and run: ```console -entc init User +ent init User ``` The command above will generate the schema for `User` under `/ent/schema/` directory: @@ -169,7 +169,7 @@ func CreateUser(ctx context.Context, client *ent.Client) (*ent.User, error) { ## Query Your Entities -`entc` generates a package for each entity schema that contains its predicates, default values, validators +`ent` generates a package for each entity schema that contains its predicates, default values, validators and additional information about storage elements (column names, primary keys, etc). ```go @@ -201,11 +201,11 @@ func QueryUser(ctx context.Context, client *ent.Client) (*ent.User, error) { ## Add Your First Edge (Relation) In this part of the tutorial, we want to declare an edge (relation) to another entity in the schema. -Let's create 2 additional entities named `Car` and `Group` with a few fields. We use `entc` +Let's create 2 additional entities named `Car` and `Group` with a few fields. We use `ent` CLI to generate the initial schemas: ```console -entc init Car Group +go run github.com/facebook/ent/cmd/ent init Car Group ``` And then we add the rest of the fields manually: @@ -437,7 +437,7 @@ relationship named `groups`. Let's define this relationship in our schemas: } ``` -We run `entc` on the schema directory to re-generate the assets. +We run `ent` on the schema directory to re-generate the assets. ```console go generate ./ent ``` diff --git a/doc/md/privacy.md b/doc/md/privacy.md index 59e5890970..f0188a2587 100644 --- a/doc/md/privacy.md +++ b/doc/md/privacy.md @@ -68,7 +68,7 @@ In order to enable the privacy option in your code generation, enable the `priva ```go package ent -//go:generate go run github.com/facebook/ent/cmd/entc generate --feature privacy ./schema +//go:generate go run github.com/facebook/ent/cmd/ent generate --feature privacy ./schema ``` 2\. If you are using the configuration from the GraphQL documentation, add the feature flag as follows: diff --git a/doc/md/schema-def.md b/doc/md/schema-def.md index f5464a6274..efe46d76b1 100755 --- a/doc/md/schema-def.md +++ b/doc/md/schema-def.md @@ -56,7 +56,7 @@ Entity schemas are usually stored inside `ent/schema` directory under the root directory of your project, and can be generated by `entc` as follows: ```console -entc init User Group +go run github.com/facebook/ent/cmd/ent init User Group ``` ## It's Just Another ORM diff --git a/doc/md/schema-fields.md b/doc/md/schema-fields.md index 71e19203ff..b3cd4ea1f4 100755 --- a/doc/md/schema-fields.md +++ b/doc/md/schema-fields.md @@ -440,7 +440,7 @@ func (User) Fields() []ent.Field { ## Additional Struct Fields -By default, `entc` generates the entity model with fields that are configured in the `schema.Fields` method. +By default, `ent` generates the entity model with fields that are configured in the `schema.Fields` method. For example, given this schema configuration: ```go diff --git a/doc/md/templates.md b/doc/md/templates.md index 5bef64a3d7..c0aaae62c0 100644 --- a/doc/md/templates.md +++ b/doc/md/templates.md @@ -3,8 +3,8 @@ id: templates title: External Templates --- -`entc` accepts external [Go templates](https://golang.org/pkg/text/template) to execute using the `--template` flag. -If the template name is already defined by `entc`, it will override the existing one. Otherwise, it will write the +`ent` accepts external [Go templates](https://golang.org/pkg/text/template) to execute using the `--template` flag. +If the template name already defined by `ent`, it will override the existing one. Otherwise, it will write the execution output to a file with the same name as the template. For example: `stringer.tmpl` - This template example will be written in a file named: `ent/stringer.go`. diff --git a/doc/md/traversals.md b/doc/md/traversals.md index cfea513f31..28026b31b7 100755 --- a/doc/md/traversals.md +++ b/doc/md/traversals.md @@ -11,7 +11,7 @@ For the purpose of the example, we'll generate the following graph: The first step is to generate the 3 schemas: `Pet`, `User`, `Group`. ```console -entc init Pet User Group +go run github.com/facebook/ent/cmd/ent init Pet User Group ``` Add the necessary fields and edges for the schemas: