Skip to content
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

Improving the goose CLI command #663

Open
mfridman opened this issue Dec 12, 2023 · 4 comments
Open

Improving the goose CLI command #663

mfridman opened this issue Dec 12, 2023 · 4 comments
Labels

Comments

@mfridman
Copy link
Collaborator

This issue aims to track improvements to the goose CLI command.

I had a version of the CLI (built with https://github.com/peterbourgon/ff) that I quite enjoyed working with. It was self-documenting, had a bunch of examples, intuitive and (most importantly) easy to compose/maintain.

image

@Albitko
Copy link

Albitko commented Dec 13, 2023

If no one else is working on this, I can take this up.
@mfridman Did I understand correctly that it is desirable to make CLI as on the screenshot?

@mfridman mfridman pinned this issue Dec 16, 2023
@mfridman
Copy link
Collaborator Author

mfridman commented Dec 16, 2023

I think this is one issue I'll likely take on over the next few months. There's a bit to this issue, and I'd like to avoid leaving a bad experience to contributors dragging out a lengthy review for a major refactor. Some items to think through:

  • We haven't done a major refactor of the CLI in ages and there's a bit of cruft to clean up
  • Use the Provider added in v3.16.0(read more here)
  • Restructure main.go and create a cli package instead of
  • Add context cancellation
  • Evaluate whether a CLI framework would serve us better (maybe not). I have some opinions on CLI frameworks, so it'd be nice to pick something that's ergonomic at the expense of supporting a lot to features
  • Depending on how we re/structure the CLI, I think we can remove the "driver" concept, and solely rely on mapping a DSN to a dialect. There's a nice package for this, https://github.com/xo/dburl
  • Stub out a way to add sub-commands, which allows us to have a hierarchy among commands.
  • Ensure we structure things in a way that we can support outputting JSON, Option to output JSON #350

... probably more, but this gives you an idea of the work involved here.

@mfridman
Copy link
Collaborator Author

I've settled on using https://pkg.go.dev/github.com/peterbourgon/ff/v4. It's got just enough knobs to make it useful and I had a fairly good experience with it in the past.

I'd like to minimize breaking changes as much as possible, but there's some quirky behavior in the current goose CLI that'll make 100% backwards compatibility near-impossible. I'll make sure to jot down any changes, although I think most of it will be welcoming.

For example, the following doesn't do what you expect:

goose create --help
2024/03/29 15:02:15 Created new file: 20240329190215_help.go

To make forward progress (without a long-lived branch) and allow folks to experiment with the "new" goose I'll guard this chunk of work with an env variable. In the future, we'll consider promoting this and removing the old code.

GOOSE_CLI=true

I'm also going to make the following 2 functions exportable, which will make it easier for folks to use the CLI code directly in their programs (fix #646) and get all the nice CLI bits.

  1. func Main()
  2. func Run(ctx context.Context, args []string, opts ...RunOptions) error { }

@mfridman
Copy link
Collaborator Author

Here's a first pass at stubbing out the new cli package. #741

I think this is a good base to iterate on, there will likely be changes and shuffles, but it's working and once it's done I've convinced this will be a nice and modern CLI user experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants