Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 79 additions & 1 deletion en/digging-deeper/artisan-console.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,67 @@ When you write console commands, it's typical to collect user input through `arg
Follow the arguments after the command:

```shell
go run . artisan send:emails NAME EMAIL
go run . artisan send:emails SUBJECT EMAIL_1 EMAIL_2
```

Definition:

```go
// send:emails <subject> <email...>
func (receiver *SendEmails) Extend() command.Extend {
return command.Extend{
Arguments: []command.Argument{
&command.ArgumentString{
Name: "subject",
Usage: "subject of email",
Required: true,
},
&command.ArgumentStringSlice{
Name: "emails",
Usage: "target emails",
Min: 1,
Max: -1,
},
},
}
}
```

Supported agrument types : `ArgumentFloat32`, `ArgumentFloat64`, `ArgumentInt`, `ArgumentInt8`, `ArgumentInt16`, `ArgumentInt32`, `ArgumentInt64`, `ArgumentString`, `ArgumentUint`, `ArgumentUint8`, `ArgumentUint16`, `ArgumentUint32`, `ArgumentUint64`, `ArgumentTimestamp`, `ArgumentFloat32Slice`, `ArgumentFloat64Slice`, `ArgumentIntSlice`, `ArgumentInt8Slice`, `ArgumentInt16Slice`, `ArgumentInt32Slice`, `ArgumentInt64Slice`, `ArgumentStringSlice`, `ArgumentUintSlice`, `ArgumentUint8Slice`, `ArgumentUint16Slice`, `ArgumentUint32Slice`, `ArgumentUint64Slice`, `ArgumentTimestampSlice`

Argument types with single value support next fields:

```go
Name string // the name of this argument
Value T // the default value of this argument
Usage string // the usage text to show
Required bool // if this argument is required
```

Slice argument types fields:

```go
Name string // the name of this argument
Value T // the default value of this argument
Usage string // the usage text to show
Min int // the min num of occurrences of this argument
Max int // the max num of occurrences of this argument, set to -1 for unlimited
```

Timestamp arguments additionally supports `Layouts []string` field, that should be filled with [supported layouts](https://pkg.go.dev/time#pkg-constants)

Get arguments:

```go
func (receiver *SendEmails) Handle(ctx console.Context) error {
subject := ctx.ArgumentString("subject")))
emails := ctx.ArgumentStringSlice("emails")))

return nil
}
```

Alternatively, it is possible to access arguments directly:
```go
func (receiver *SendEmails) Handle(ctx console.Context) error {
name := ctx.Argument(0)
Expand Down Expand Up @@ -369,6 +425,19 @@ func (receiver *SendEmails) Handle(ctx console.Context) error {
}
```

There are few helpers to write to console with respective color:

```go
ctx.Green("This is a green message")
ctx.Greenln("This is a green line message")
ctx.Red("This is a red message")
ctx.Redln("This is a red line message")
ctx.Yellow("This is a yellow message")
ctx.Yellowln("This is a yellow line message")
ctx.Black("This is a black message")
ctx.Blackln("This is a black line message")
```

You can use the `NewLine` method to write a new line to the console:

```go
Expand Down Expand Up @@ -424,6 +493,15 @@ err := ctx.Spinner("Loading...", console.SpinnerOption{
})
```

### Divider

To show terminal-width divider you may use `Divider` method.

```go
ctx.Divider() // ----------
ctx.Divider("=>") // =>=>=>=>=>
```

## Category

You can set a set of commands to the same category, convenient in `go run . artisan list`:
Expand Down
2 changes: 1 addition & 1 deletion en/getting-started/contributions.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ You can find or create an issue in [Issue List](https://github.com/goravel/gorav
- You can check out [this article](https://docs.github.com/en/get-started/quickstart/contributing-to-projects) if you are new to the process;
- During the development process, if you encounter a problem, you can describe the problem in detail in issue at any time for future communication, but before that, please make sure that you have tried to solve the problem through Google and other methods as much as possible;
- Before creating a PR, please improve the unit test coverage as much as possible to provide more stable functions;
- If you modify any file under the `contracts` folder, please run the `go run github.com/vektra/mockery/v2` command in the root directory to generate the mock file;
- If you modify any file under the `contracts` folder, please run the `go tool mockery` command in the root directory to generate the mock file;
- When the PR is developed, please add the `Review Ready `, the maintainer will review it in a timely manner.
- After the PR is merged, the issue will be closed automatically if the description in the PR is set correctly;
- Goravel greatly appreciates your contribution and will add you to the home contribution list at the next release; ❀️
Expand Down
15 changes: 14 additions & 1 deletion en/getting-started/packages.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Excellent Extend Packages

You can find extended packages for Goravel here, and you can also create a PR for [goravel/docs](https://github.com/goravel/docs) to commit your owner package, please improve the test coverage of your package as much as possible.
| Package | Description | Test Coverage |

| Package | Description | Test Coverage* |
| --------------------------------------------------------------------------------- | --------------------------------------------- | ------------- |
| [goravel/gin](https://github.com/goravel/gin) | The Gin driver for `facades.Route()` | 83.1% |
| [goravel/fiber](https://github.com/goravel/fiber) | The Fiber driver for `facades.Route()` | 81.0% |
Expand All @@ -12,7 +13,19 @@ You can find extended packages for Goravel here, and you can also create a PR fo
| [goravel/oss](https://github.com/goravel/oss) | A OSS disk driver for `facades.Storage()` | 76.5% |
| [goravel/installer](https://github.com/goravel/installer) | Goravel installer | 76.2% |
| [goravel/cloudinary](https://github.com/goravel/cloudinary) | A Cloudinary disk driver for `facades.Storage() | 75.4% |
| [portofolio-mager/goravel-mongodb](https://github.com/portofolio-mager/goravel-mongodb) | A MongoDB package | 16.9% |
| [hulutech-web/goravel-workflow](https://github.com/hulutech-web/goravel-workflow) | A workflow package | 4.4% |
| [hulutech-web/goravel-crud](https://github.com/hulutech-web/goravel-crud) | A goravel crud package | 4.2% |
| [hulutech-web/tinker](https://github.com/hulutech-web/tinker) | A goravel tinker package | 3.6% |
| [hulutech-web/goravel-socket](https://github.com/hulutech-web/goravel-socket) | A webSocket package | 0% |

***Note**: The packages have been ordered based on their test rate.

πŸ’‘ Tip: To help more developers discover your work, you can also add relevant topics to your repository.
Recommended topic: [`goravel-package`](https://github.com/topics/goravel-package)

- On GitHub, navigate to the main page of the repository.
- In the top right corner of the page, to the right of "About", click gear icon (settings).
- Under "Topics", start to type the topic you want to add to your repository to display a dropdown menu of any matching topics.
- Click the topic you want to add or continue typing to create a new topic. For example: `goravel-package`, `goravel` and any other relevant keywords.
- Click `Save changes` β€” this will make your package more discoverable.