-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add comprehensive CLI documentation and examples #2220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Add comprehensive CLI documentation and examples #2220
Conversation
Release/v1.42.3
* doc: gofr/grpc package documentation overview * doc: gofr/datasource package documentation overview * doc: gofr/file package documentation overview * doc: add a dot in the end of a package overview comment for consistency * fix: move grpc package go doc comment to an actual grpc package * docs: fix MongoDB time import and ClickHouse data types - Add missing 'time' import in MongoDB example that uses time.Second - Fix ClickHouse User struct Age field type from string to int - Fix ClickHouse INSERT to use integer value instead of string - Fix typo: 'successful inserted' -> 'successfully inserted' - Revert version file change to 'dev' as requested These changes ensure MongoDB example compiles and ClickHouse example uses consistent data types between struct and INSERT statement. * docs: update package comment for datasource to reflect current usage * docs: fix Dgraph port to use correct gRPC port 9080 DGraph uses gRPC and the default gRPC port is 9080, not 8080. This ensures the example uses the correct port for DGraph connections. * Apply suggestions from code review Co-authored-by: Divya Darshana <[email protected]> * docs: update packages comments according to review * Update pkg/gofr/file/file.go Co-authored-by: Divya Darshana <[email protected]> * build(deps): bump gofr.dev in /examples/using-add-filestore Bumps [gofr.dev](https://github.com/gofr-dev/gofr) from 1.42.2 to 1.42.3. - [Release notes](https://github.com/gofr-dev/gofr/releases) - [Commits](gofr-dev/gofr@v1.42.2...v1.42.3) --- updated-dependencies: - dependency-name: gofr.dev dependency-version: 1.42.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump gofr.dev in /pkg/gofr/datasource/file/ftp Bumps [gofr.dev](https://github.com/gofr-dev/gofr) from 1.42.2 to 1.42.3. - [Release notes](https://github.com/gofr-dev/gofr/releases) - [Commits](gofr-dev/gofr@v1.42.2...v1.42.3) --- updated-dependencies: - dependency-name: gofr.dev dependency-version: 1.42.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump golang.org/x/term from 0.32.0 to 0.33.0 Bumps [golang.org/x/term](https://github.com/golang/term) from 0.32.0 to 0.33.0. - [Commits](golang/term@v0.32.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/term dependency-version: 0.33.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump gofr.dev in /pkg/gofr/datasource/pubsub/eventhub Bumps [gofr.dev](https://github.com/gofr-dev/gofr) from 1.42.2 to 1.42.3. - [Release notes](https://github.com/gofr-dev/gofr/releases) - [Commits](gofr-dev/gofr@v1.42.2...v1.42.3) --- updated-dependencies: - dependency-name: gofr.dev dependency-version: 1.42.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump google.golang.org/api from 0.238.0 to 0.241.0 Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.238.0 to 0.241.0. - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](googleapis/google-api-go-client@v0.238.0...v0.241.0) --- updated-dependencies: - dependency-name: google.golang.org/api dependency-version: 0.241.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump github.com/surrealdb/surrealdb.go Bumps [github.com/surrealdb/surrealdb.go](https://github.com/surrealdb/surrealdb.go) from 0.3.2 to 0.3.3. - [Release notes](https://github.com/surrealdb/surrealdb.go/releases) - [Changelog](https://github.com/surrealdb/surrealdb.go/blob/main/RELEASE_NOTES.md) - [Commits](surrealdb/surrealdb.go@v0.3.2...v0.3.3) --- updated-dependencies: - dependency-name: github.com/surrealdb/surrealdb.go dependency-version: 0.3.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump github.com/redis/go-redis/extra/redisotel/v9 Bumps [github.com/redis/go-redis/extra/redisotel/v9](https://github.com/redis/go-redis) from 9.10.0 to 9.11.0. - [Release notes](https://github.com/redis/go-redis/releases) - [Changelog](https://github.com/redis/go-redis/blob/master/CHANGELOG.md) - [Commits](redis/go-redis@v9.10.0...v9.11.0) --- updated-dependencies: - dependency-name: github.com/redis/go-redis/extra/redisotel/v9 dependency-version: 9.11.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump gofr.dev in /pkg/gofr/datasource/file/s3 Bumps [gofr.dev](https://github.com/gofr-dev/gofr) from 1.42.2 to 1.42.3. - [Release notes](https://github.com/gofr-dev/gofr/releases) - [Commits](gofr-dev/gofr@v1.42.2...v1.42.3) --- updated-dependencies: - dependency-name: gofr.dev dependency-version: 1.42.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump gofr.dev in /pkg/gofr/datasource/file/sftp Bumps [gofr.dev](https://github.com/gofr-dev/gofr) from 1.42.2 to 1.42.3. - [Release notes](https://github.com/gofr-dev/gofr/releases) - [Commits](gofr-dev/gofr@v1.42.2...v1.42.3) --- updated-dependencies: - dependency-name: gofr.dev dependency-version: 1.42.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump gofr.dev in /pkg/gofr/datasource/pubsub/nats Bumps [gofr.dev](https://github.com/gofr-dev/gofr) from 1.42.2 to 1.42.3. - [Release notes](https://github.com/gofr-dev/gofr/releases) - [Commits](gofr-dev/gofr@v1.42.2...v1.42.3) --- updated-dependencies: - dependency-name: gofr.dev dependency-version: 1.42.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump golang.org/x/text from 0.26.0 to 0.27.0 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.26.0 to 0.27.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](golang/text@v0.26.0...v0.27.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-version: 0.27.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * add missing table end tag in redis documentation * Update page.md Fix and clean up ScyllaDB documentation example * fix and clean up ScyllaDB documentation example * refactor newContext to avoid creating contextLogger separately * fix tests * resolve linter * remove context embedding in cmd struct and add contextLogger in newCMD method * Elasticsearch migration (gofr-dev#2051) * fixed docs rendering issue * minor fix * add elasticsearch documentation * minor fix * Remove redundant docs (gofr-dev#2093) * skip-coverage-workflow (gofr-dev#2094) --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: olxandr <[email protected]> Co-authored-by: olxandr <[email protected]> Co-authored-by: SAMMILLERR <[email protected]> Co-authored-by: Divya Darshana <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Vikash Kumar <[email protected]> Co-authored-by: Dhruv Rishikesh Janakala <[email protected]> Co-authored-by: Arihant Pal <[email protected]> Co-authored-by: Zopdev <[email protected]> Co-authored-by: coolwednesday <[email protected]>
* Merge pull request gofr-dev#2067 from sathwikshetty33/development * build(deps): bump gofr.dev in /examples/using-add-filestore (gofr-dev#2097) * build(deps): bump modernc.org/sqlite from 1.38.0 to 1.38.1 (gofr-dev#2099) * build(deps): bump gofr.dev in /pkg/gofr/datasource/pubsub/eventhub (gofr-dev#2106) * build(deps): bump gofr.dev in /pkg/gofr/datasource/file/ftp (gofr-dev#2100) * build(deps): bump gofr.dev in /pkg/gofr/datasource/pubsub/nats (gofr-dev#2108) * build(deps): bump google.golang.org/grpc from 1.73.0 to 1.74.2 (gofr-dev#2098) * build(deps): bump github.com/golang-jwt/jwt/v5 from 5.2.2 to 5.2.3 (gofr-dev#2101) * build(deps): bump github.com/ClickHouse/clickhouse-go/v2 (gofr-dev#2102) * build(deps): bump google.golang.org/grpc in /pkg/gofr/datasource/dgraph (gofr-dev#2107) * build(deps): bump gofr.dev in /pkg/gofr/datasource/file/sftp (gofr-dev#2104) * build(deps): bump gofr.dev in /pkg/gofr/datasource/file/s3 (gofr-dev#2105) * build(deps): bump google.golang.org/api from 0.241.0 to 0.243.0 (gofr-dev#2103) * Scylla migration support (gofr-dev#2085) * update release version to v1.42.5 --------- Co-authored-by: Sathwik Shetty <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Om Kulkarni <[email protected]>
* Fix/pubsub migration get last version (gofr-dev#2119) * add chaining of next migrator in getLastVersion method of pubsub.go * fix linter * feat: add OnStart hook for synchronous startup jobs (gofr-dev#2079) * feat: improve OnStart hook with DI context, update docs, and ensure code quality * refactor: improve OnStart hook context, move logic to method, and test DI access * feat(onstart): implement all reviewer feedback - Move OnStart logic to a dedicated, testable method. - Fix all linter issues (deep-exit and cyclomatic complexity). - Add unit tests for success and error cases. - Add comprehensive documentation with a realistic example. - Update the example app to demonstrate a real-world use case. * fix: improve startup error handling for OnStart hooks (graceful shutdown on context cancel) * fix: address linter errors in OnStart tests - Fix dynamic error definition - Fix unused parameters with underscore - Use t.Context() instead of context.Background() - Use assert.NoError instead of assert.Nil * fix: remove os.Exit call to resolve deep-exit linter error * fix: resolve remaining linter errors - Fix cuddled return statement in newContextForHooks - Fix cuddled assignment in OnStart test - Remove os.Exit call to resolve deep-exit error * refactor: remove newContextForHooks and reuse existing newContext function * fix: resolve linting errors and refactor Run() method for better maintainability - Fix err113: Replace dynamic error creation with static error in TestApp_OnStart - Fix gocyclo: Refactor Run() method by extracting helper methods to reduce cyclomatic complexity - Fix ws1: Correct whitespace issues in gofr_test.go and run.go - Add helper methods: handleStartupHooks, startShutdownHandler, startTelemetryIfEnabled, startAllServers - Improve code organization and readability while maintaining functionality * fix: resolve remaining linting issues in TestApp_OnStart - Fix err113: Move error variable to package level to avoid dynamic error creation - Fix error-naming: Rename hookFailedErr to errHookFailed following Go naming conventions - Fix whitespace: Remove unnecessary blank line before app assignment - All linting issues in modified files are now resolved * fix: resolve godot and wsl linter errors in run.go and gofr_test.go * Update go.work.sum * fix: restore comments as requested by reviewer * Update run.go * Update run.go * fix: address reviewer comments - add godoc comment to OnStart method and move startup-hooks.md to proper directory structure * fix: restore metrics server comments and ensure OnStart hook runs before route registration * fix: implement proper context usage in runOnStartHooks and fix example API usage * Update go.work.sum * fix: correct spelling of 'canceled' in comment * minor documentation fix * revert go.sum changes * Update pkg/gofr/gofr_test.go Co-authored-by: ccoVeille <[email protected]> * revert go.work.sum changes --------- Co-authored-by: HeerakKashyap <[email protected]> Co-authored-by: Umang Mundhra <[email protected]> Co-authored-by: coolwednesday <[email protected]> Co-authored-by: Divya Darshana <[email protected]> Co-authored-by: ccoVeille <[email protected]> * build(deps): bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.22.0 to 1.23.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](prometheus/client_golang@v1.22.0...v1.23.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-version: 1.23.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump go.opentelemetry.io/otel/exporters/prometheus Bumps [go.opentelemetry.io/otel/exporters/prometheus](https://github.com/open-telemetry/opentelemetry-go) from 0.59.0 to 0.59.1. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-go@exporters/prometheus/v0.59.0...exporters/prometheus/v0.59.1) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel/exporters/prometheus dependency-version: 0.59.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump gofr.dev in /examples/using-add-filestore Bumps [gofr.dev](https://github.com/gofr-dev/gofr) from 1.42.4 to 1.42.5. - [Release notes](https://github.com/gofr-dev/gofr/releases) - [Commits](gofr-dev/gofr@v1.42.4...v1.42.5) --- updated-dependencies: - dependency-name: gofr.dev dependency-version: 1.42.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump github.com/ClickHouse/clickhouse-go/v2 Bumps [github.com/ClickHouse/clickhouse-go/v2](https://github.com/ClickHouse/clickhouse-go) from 2.39.0 to 2.40.1. - [Release notes](https://github.com/ClickHouse/clickhouse-go/releases) - [Changelog](https://github.com/ClickHouse/clickhouse-go/blob/main/CHANGELOG.md) - [Commits](ClickHouse/clickhouse-go@v2.39.0...v2.40.1) --- updated-dependencies: - dependency-name: github.com/ClickHouse/clickhouse-go/v2 dependency-version: 2.40.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump crate-ci/typos in the actions group Bumps the actions group with 1 update: [crate-ci/typos](https://github.com/crate-ci/typos). Updates `crate-ci/typos` from 1.34.0 to 1.35.1 - [Release notes](https://github.com/crate-ci/typos/releases) - [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md) - [Commits](crate-ci/typos@v1.34.0...v1.35.1) --- updated-dependencies: - dependency-name: crate-ci/typos dependency-version: 1.35.1 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump github.com/prometheus/client_golang Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.22.0 to 1.23.0. - [Release notes](https://github.com/prometheus/client_golang/releases) - [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md) - [Commits](prometheus/client_golang@v1.22.0...v1.23.0) --- updated-dependencies: - dependency-name: github.com/prometheus/client_golang dependency-version: 1.23.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump google.golang.org/api from 0.243.0 to 0.244.0 Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.243.0 to 0.244.0. - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](googleapis/google-api-go-client@v0.243.0...v0.244.0) --- updated-dependencies: - dependency-name: google.golang.org/api dependency-version: 0.244.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump modernc.org/sqlite from 1.38.1 to 1.38.2 Bumps [modernc.org/sqlite](https://gitlab.com/cznic/sqlite) from 1.38.1 to 1.38.2. - [Commits](https://gitlab.com/cznic/sqlite/compare/v1.38.1...v1.38.2) --- updated-dependencies: - dependency-name: modernc.org/sqlite dependency-version: 1.38.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump github.com/golang-jwt/jwt/v5 from 5.2.3 to 5.3.0 Bumps [github.com/golang-jwt/jwt/v5](https://github.com/golang-jwt/jwt) from 5.2.3 to 5.3.0. - [Release notes](https://github.com/golang-jwt/jwt/releases) - [Changelog](https://github.com/golang-jwt/jwt/blob/main/VERSION_HISTORY.md) - [Commits](golang-jwt/jwt@v5.2.3...v5.3.0) --- updated-dependencies: - dependency-name: github.com/golang-jwt/jwt/v5 dependency-version: 5.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Merge pull request gofr-dev#2135 from gofr-dev/fix-docs * update release version to v1.43.0 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: HootingConjuror <[email protected]> Co-authored-by: HeerakKashyap <[email protected]> Co-authored-by: coolwednesday <[email protected]> Co-authored-by: Divya Darshana <[email protected]> Co-authored-by: ccoVeille <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Release/v1.44.0
- Add complete CLI documentation (docs/cli/cli.md) - Add CLI examples with manual argument parsing - Add navigation support for CLI docs - Include both single and multi-subcommand examples - Document current GoFr version limitations and manual parsing approach
@coolwednesday can u review this? |
@@ -1,3 +1,3 @@ | |||
package version | |||
|
|||
const Framework = "dev" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not needed please revert it.
@@ -1156,6 +1156,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An | |||
github.com/spiffe/go-spiffe/v2 v2.5.0 h1:N2I01KCUkv1FAjZXJMwh95KK1ZIQLYbPfhaxw8WS0hE= | |||
github.com/spiffe/go-spiffe/v2 v2.5.0/go.mod h1:P+NxobPc6wXhVtINNtFjNWGBTreew1GBUCwT2wPmb7g= | |||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | |||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel all the changes in the go.work.sum
are not related to scope of this PR so please revert them back.
@@ -0,0 +1,427 @@ | |||
# Building CLI Applications with GoFr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for such a detailed documentation but having so much can actually confuse the user on what's important and what's for the info only.
I will kindly request you to make a simple short yet informatic documentation giving all the necessary commands and method that GoFr provides along with a small example and only the most necessary info. Please feel free to visit our https://gofr.dev/docs website to refer how other docs are written.
@aryaman-vohra For the issue #2075 we need to add a documentation for CLI but no need to write a new CLI example. If you want to update the readme please update sample cmd example readme. Please remove the newly added example as we already have one cmd example. |
📝 What This PR Adds:
✅ Complete CLI Documentation
docs/cli/cli.md
- Comprehensive guide for building CLI applicationsdocs/navigation.js
with CLI entry✅ Working CLI Examples
Multi-subcommand example:
examples/cli-example/example1-mutli-sub-command/main.go
hello
andgoodbye
subcommands--name
) and positional argument parsingSingle subcommand example:
examples/cli-example/example2-single-sub-command/main.go
hello
command with manual argument parsingDocumentation:
examples/cli-example/README.md
with usage instructions✅ Key Features Demonstrated:
os.Args
and helper functions--name value
) and positional arguments✅ Documentation Quality:
🎯 Impact:
This PR provides users with complete documentation and working examples for building CLI applications with the current GoFr version, addressing the lack of CLI documentation in the project.
📋 Files Changed:
docs/cli/cli.md
examples/cli-example/README.md
examples/cli-example/example1-mutli-sub-command/main.go
examples/cli-example/example2-single-sub-command/main.go
docs/navigation.js
🧪 Testing:
All examples are tested and working with the current GoFr version. Users can run: