Coder Social home page Coder Social logo

sqlc-restruct's Introduction

sqlc-restruct

EXPERIMENTAL!

Post-processor for kyleconroy/sqlc

overview
user@host:~$ sqlc-restruct --help
NAME:
   sqlc-restruct - Post-processor for kyleconroy/sqlc

USAGE:
   sqlc-restruct [global options] command [command options] [arguments...]

COMMANDS:
   separate-interface  Separates models and the `Querier` interface from the `Queries` struct. This is typically done to adhere to the Dependency Inversion Principle (DIP), allowing for more flexible and testable code.
   help, h             Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h  show help

Installation

go install github.com/mpyw/sqlc-restruct/cmd/sqlc-restruct@latest

SubCommands

user@host:~$ sqlc-restruct separate-interface --help
NAME:
   sqlc-restruct separate-interface - Separates models and the `Querier` interface from the `Queries` struct. This is typically done to adhere to the Dependency Inversion Principle (DIP), allowing for more flexible and testable code.

USAGE:
   sqlc-restruct separate-interface [command options] [arguments...]

OPTIONS:
   --iface-pkg-name value     The package name where the separated Querier will be located.
   --iface-pkg-url value      The package URL where the separated Querier will be located. (e.g. "github.com/<user>/<repo>/path/to/pkg")
   --iface-dir value          The directory path where the separated Querier will be located.
   --models-pkg-name value    The package name where the separated models will be located. (default: --models-pkg-name value)
   --models-pkg-url value     The package URL where the separated models will be located. (default: --models-pkg-url value)
   --models-dir value         The directory path where the separated models will be located. (default: --iface-dir value)
   --impl-dir value           The original directory where the sqlc-generated code is located. (default: ".")
   --impl-sql-suffix value    The suffix for sqlc-generated files from SQL files. (default: ".sql.go")
   --models-file-name value   The file name for the sqlc-generated models file. (default: "models.go")
   --querier-file-name value  The file name for the sqlc-generated Querier file. (default: "querier.go")
   --help, -h                 show help

We recommend chaining the //go:generate directive for sqlc-restruct right after the one for sqlc in your code.

//go:generate sqlc generate
//go:generate sqlc-restruct separate-interface --iface-dir=domain/repos --iface-pkg-name=repos --iface-pkg-url=github.com/example/domain/repos

sqlc-restruct's People

Contributors

mpyw avatar mrehbr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mrehbr

sqlc-restruct's Issues

Feature: Renaming Querier/Queries

Renaming elements like structs in models is quite simple with gorename, so there's no pressing need to create a feature for this.

However, the case for Querier and Queries is different. These are incredibly generic names, and there may be times when you would like to use these names for elements not generated by sqlc. To accommodate such scenarios with flexibility, we will implement a feature that allows you to freely assign names to these.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.