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

Feature request: buf config ls-modules #3035

Closed
doriable opened this issue May 30, 2024 · 1 comment · Fixed by #3081
Closed

Feature request: buf config ls-modules #3035

doriable opened this issue May 30, 2024 · 1 comment · Fixed by #3081
Labels
Feature New feature or request

Comments

@doriable
Copy link
Member

doriable commented May 30, 2024

I am interested in a command that gives me the list of configured modules.

buf config ls-modules <path>

It takes up to one argument, which is a path to a module or workspace root (where the configuration file lives). This path defaults to . when left empty.

For example, if I have a workspace that has a v2 buf.yaml that looks like the following:

version: v2
name: buf.build/dkeung/playground
modules:
  - path: proto
    name: buf.build/foo/foo
  - path: vendor

In a directory tree that looks like the following:

$ tree
.
├── buf.yaml
├── proto
│       └── ...
├── vendor
│       └── ...
└── ...

I want something that does the following, assume all commands are run at .:

$ buf config ls-modules
Path            Name
proto           buf.build/foo/foo
vendor


$ buf config ls-modules --names-only
buf.build/foo/foo

$ buf config ls-modules --paths-only
proto
vendor

$ buf config ls-modules --names-only --paths-only
Failure: cannot set --names-only --paths-only together

The path will always be the module root and the name is the module name, if one is available. For remote modules, the root of a remote module is always ., since the remote reference will always "start at its root".

@doriable
Copy link
Member Author

doriable commented May 30, 2024

For v1 workspaces, I would expect the following:

version: v1
directories:
  - proto
  - vendor

# buf.yaml in proto
version: v1
name: buf.build/foo/foo

$ tree
.
├── buf.work.yaml
├── proto
│       └── buf.yaml
├── vendor
│       └── ...
└── ...


$ buf config ls-modules
Path            Name
proto           buf.build/foo/foo
vendor

$ buf config ls-modules --names-only
buf.build/foo/foo

$ buf config ls-modules --paths-only
proto
vendor

$ buf config ls-modules proto
Path       Name
.          buf.build/foo/foo

For v1 modules, it will always only ever print one module output:

# buf.yaml in proto
version: v1
name: buf.build/foo/foo

$ tree
.
├── proto
│       └── buf.yaml
└── ...

$ buf config ls-modules proto
Path       Name
.          buf.build/foo/foo

$ buf config ls-modules proto --names-only
buf.build/foo/foo

$ buf config ls-modules proto --paths-only
.

@doriable doriable changed the title Feature request: buf ls-modules Feature request: buf config ls-modules May 30, 2024
@doriable doriable added the Feature New feature or request label Jun 10, 2024
oliversun9 added a commit that referenced this issue Jun 21, 2024
Fixes #3035.

---------

Co-authored-by: Oliver Sun <73540835+oliversun9@users.noreply.github.com>
Co-authored-by: Oliver Sun <osun@buf.build>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant