Repository: bufbuild/buf
Pull request #942 (2022-02-15 00:47:24)

Remove `buf config` and move commands to `mod` and `beta` respectively
After some discussion, we've decided to remove `buf config` and consolidate most commands under `buf mod`.
The only exception is the `migrate-v1beta1` command, which has been moved to `buf beta`.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb3fef020..b1fd52f16 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,11 @@
   details.
 - Context modifier no longer overrides an existing token on the context. This allows `buf registry login`
   to properly check the user provided token without the token being overriden by the CLI interceptor.
+- Removed the `buf config init` command in favor of `buf mod init`.
+- Removed the `buf config ls-breaking-rules` command in favor of `buf mod ls-breaking-rules`.
+- Removed the `buf config ls-lint-rules` command in favor of `buf mod ls-lint-rules`.
+- Removed the `buf config migrate-v1beta1` command in favor of `buf beta migrate-v1beta1`.
+- Add `buf beta decode` command to decode message with provided image source and message type.
 
 ## [v1.0.0-rc12] - 2022-02-01
 
diff --git a/private/buf/cmd/buf/buf.go b/private/buf/cmd/buf/buf.go
index e1c2d9534..c85b582af 100644
--- a/private/buf/cmd/buf/buf.go
+++ b/private/buf/cmd/buf/buf.go
@@ -25,6 +25,7 @@ import (
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokenget"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokenlist"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/decode"
+	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/migratev1beta1"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/commit/commitget"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/commit/commitlist"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/organization/organizationcreate"
@@ -55,15 +56,14 @@ import (
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/track/tracklist"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/breaking"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/build"
-	"github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configinit"
-	"github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configlsbreakingrules"
-	"github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configlslintrules"
-	"github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configmigratev1beta1"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/export"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/generate"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/lint"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/lsfiles"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modclearcache"
+	"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modinit"
+	"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modlsbreakingrules"
+	"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modlslintrules"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modopen"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modprune"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modupdate"
@@ -107,20 +107,13 @@ func NewRootCommand(name string) *appcmd.Command {
 				Use:   "mod",
 				Short: "Manage Buf modules.",
 				SubCommands: []*appcmd.Command{
+					modinit.NewCommand("init", builder),
 					modprune.NewCommand("prune", builder),
 					modupdate.NewCommand("update", builder),
 					modopen.NewCommand("open", builder),
 					modclearcache.NewCommand("clear-cache", builder, "cc"),
-				},
-			},
-			{
-				Use:   "config",
-				Short: "Manage Buf module configuration.",
-				SubCommands: []*appcmd.Command{
-					configinit.NewCommand("init", builder),
-					configlslintrules.NewCommand("ls-lint-rules", builder),
-					configlsbreakingrules.NewCommand("ls-breaking-rules", builder),
-					configmigratev1beta1.NewCommand("migrate-v1beta1", builder),
+					modlslintrules.NewCommand("ls-lint-rules", builder),
+					modlsbreakingrules.NewCommand("ls-breaking-rules", builder),
 				},
 			},
 			{
@@ -136,6 +129,7 @@ func NewRootCommand(name string) *appcmd.Command {
 				Short: "Beta commands. Unstable and likely to change.",
 				SubCommands: []*appcmd.Command{
 					decode.NewCommand("decode", builder),
+					migratev1beta1.NewCommand("migrate-v1beta1", builder),
 					{
 						Use:   "registry",
 						Short: "Manage assets on the Buf Schema Registry.",
diff --git a/private/buf/cmd/buf/command/config/configmigratev1beta1/configmigratev1beta1.go b/private/buf/cmd/buf/command/beta/migratev1beta1/migratev1beta1.go
similarity index 98%
rename from private/buf/cmd/buf/command/config/configmigratev1beta1/configmigratev1beta1.go
rename to private/buf/cmd/buf/command/beta/migratev1beta1/migratev1beta1.go
index 47cffa32c..d64d76b35 100644
--- a/private/buf/cmd/buf/command/config/configmigratev1beta1/configmigratev1beta1.go
+++ b/private/buf/cmd/buf/command/beta/migratev1beta1/migratev1beta1.go
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package configmigratev1beta1
+package migratev1beta1
 
 import (
 	"context"
diff --git a/private/buf/cmd/buf/command/config/configlslintrules/usage.gen.go b/private/buf/cmd/buf/command/beta/migratev1beta1/usage.gen.go
similarity index 96%
rename from private/buf/cmd/buf/command/config/configlslintrules/usage.gen.go
rename to private/buf/cmd/buf/command/beta/migratev1beta1/usage.gen.go
index 7aa76f771..05a6adb68 100644
--- a/private/buf/cmd/buf/command/config/configlslintrules/usage.gen.go
+++ b/private/buf/cmd/buf/command/beta/migratev1beta1/usage.gen.go
@@ -14,6 +14,6 @@
 
 // Generated. DO NOT EDIT.
 
-package configlslintrules
+package migratev1beta1
 
 import _ "github.com/bufbuild/buf/private/usage"
diff --git a/private/buf/cmd/buf/command/config/internal/internal.go b/private/buf/cmd/buf/command/mod/internal/internal.go
similarity index 100%
rename from private/buf/cmd/buf/command/config/internal/internal.go
rename to private/buf/cmd/buf/command/mod/internal/internal.go
diff --git a/private/buf/cmd/buf/command/config/internal/usage.gen.go b/private/buf/cmd/buf/command/mod/internal/usage.gen.go
similarity index 100%
rename from private/buf/cmd/buf/command/config/internal/usage.gen.go
rename to private/buf/cmd/buf/command/mod/internal/usage.gen.go
diff --git a/private/buf/cmd/buf/command/config/configinit/configinit.go b/private/buf/cmd/buf/command/mod/modinit/modinit.go
similarity index 99%
rename from private/buf/cmd/buf/command/config/configinit/configinit.go
rename to private/buf/cmd/buf/command/mod/modinit/modinit.go
index ff6a2dcf9..01f19f9ef 100644
--- a/private/buf/cmd/buf/command/config/configinit/configinit.go
+++ b/private/buf/cmd/buf/command/mod/modinit/modinit.go
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package configinit
+package modinit
 
 import (
 	"context"
diff --git a/private/buf/cmd/buf/command/config/configinit/usage.gen.go b/private/buf/cmd/buf/command/mod/modinit/usage.gen.go
similarity index 97%
rename from private/buf/cmd/buf/command/config/configinit/usage.gen.go
rename to private/buf/cmd/buf/command/mod/modinit/usage.gen.go
index 55311aaea..14ba321d8 100644
--- a/private/buf/cmd/buf/command/config/configinit/usage.gen.go
+++ b/private/buf/cmd/buf/command/mod/modinit/usage.gen.go
@@ -14,6 +14,6 @@
 
 // Generated. DO NOT EDIT.
 
-package configinit
+package modinit
 
 import _ "github.com/bufbuild/buf/private/usage"
diff --git a/private/buf/cmd/buf/command/config/configlsbreakingrules/configlsbreakingrules.go b/private/buf/cmd/buf/command/mod/modlsbreakingrules/modlsbreakingrules.go
similarity index 88%
rename from private/buf/cmd/buf/command/config/configlsbreakingrules/configlsbreakingrules.go
rename to private/buf/cmd/buf/command/mod/modlsbreakingrules/modlsbreakingrules.go
index 38822295f..f493a410c 100644
--- a/private/buf/cmd/buf/command/config/configlsbreakingrules/configlsbreakingrules.go
+++ b/private/buf/cmd/buf/command/mod/modlsbreakingrules/modlsbreakingrules.go
@@ -12,13 +12,13 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package configlsbreakingrules
+package modlsbreakingrules
 
 import (
 	"context"
 	"fmt"
 
-	configinternal "github.com/bufbuild/buf/private/buf/cmd/buf/command/config/internal"
+	modinternal "github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/internal"
 	"github.com/bufbuild/buf/private/bufpkg/bufcheck"
 	"github.com/bufbuild/buf/private/bufpkg/bufcheck/bufbreaking"
 	"github.com/bufbuild/buf/private/bufpkg/bufconfig"
@@ -67,10 +67,10 @@ func newFlags() *flags {
 }
 
 func (f *flags) Bind(flagSet *pflag.FlagSet) {
-	configinternal.BindLSRulesAll(flagSet, &f.All, allFlagName)
-	configinternal.BindLSRulesConfig(flagSet, &f.Config, configFlagName, allFlagName, versionFlagName)
-	configinternal.BindLSRulesFormat(flagSet, &f.Format, formatFlagName)
-	configinternal.BindLSRulesVersion(flagSet, &f.Version, versionFlagName, allFlagName)
+	modinternal.BindLSRulesAll(flagSet, &f.All, allFlagName)
+	modinternal.BindLSRulesConfig(flagSet, &f.Config, configFlagName, allFlagName, versionFlagName)
+	modinternal.BindLSRulesFormat(flagSet, &f.Format, formatFlagName)
+	modinternal.BindLSRulesVersion(flagSet, &f.Version, versionFlagName, allFlagName)
 }
 
 func run(
diff --git a/private/buf/cmd/buf/command/config/configmigratev1beta1/usage.gen.go b/private/buf/cmd/buf/command/mod/modlsbreakingrules/usage.gen.go
similarity index 95%
rename from private/buf/cmd/buf/command/config/configmigratev1beta1/usage.gen.go
rename to private/buf/cmd/buf/command/mod/modlsbreakingrules/usage.gen.go
index 73cbd68e2..873d6b6f7 100644
--- a/private/buf/cmd/buf/command/config/configmigratev1beta1/usage.gen.go
+++ b/private/buf/cmd/buf/command/mod/modlsbreakingrules/usage.gen.go
@@ -14,6 +14,6 @@
 
 // Generated. DO NOT EDIT.
 
-package configmigratev1beta1
+package modlsbreakingrules
 
 import _ "github.com/bufbuild/buf/private/usage"
diff --git a/private/buf/cmd/buf/command/config/configlslintrules/configlslintrules.go b/private/buf/cmd/buf/command/mod/modlslintrules/modlslintrules.go
similarity index 88%
rename from private/buf/cmd/buf/command/config/configlslintrules/configlslintrules.go
rename to private/buf/cmd/buf/command/mod/modlslintrules/modlslintrules.go
index 8442cfb22..cc81e50ac 100644
--- a/private/buf/cmd/buf/command/config/configlslintrules/configlslintrules.go
+++ b/private/buf/cmd/buf/command/mod/modlslintrules/modlslintrules.go
@@ -12,13 +12,13 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package configlslintrules
+package modlslintrules
 
 import (
 	"context"
 	"fmt"
 
-	configinternal "github.com/bufbuild/buf/private/buf/cmd/buf/command/config/internal"
+	modinternal "github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/internal"
 	"github.com/bufbuild/buf/private/bufpkg/bufcheck"
 	"github.com/bufbuild/buf/private/bufpkg/bufcheck/buflint"
 	"github.com/bufbuild/buf/private/bufpkg/bufconfig"
@@ -67,10 +67,10 @@ func newFlags() *flags {
 }
 
 func (f *flags) Bind(flagSet *pflag.FlagSet) {
-	configinternal.BindLSRulesAll(flagSet, &f.All, allFlagName)
-	configinternal.BindLSRulesConfig(flagSet, &f.Config, configFlagName, allFlagName, versionFlagName)
-	configinternal.BindLSRulesFormat(flagSet, &f.Format, formatFlagName)
-	configinternal.BindLSRulesVersion(flagSet, &f.Version, versionFlagName, allFlagName)
+	modinternal.BindLSRulesAll(flagSet, &f.All, allFlagName)
+	modinternal.BindLSRulesConfig(flagSet, &f.Config, configFlagName, allFlagName, versionFlagName)
+	modinternal.BindLSRulesFormat(flagSet, &f.Format, formatFlagName)
+	modinternal.BindLSRulesVersion(flagSet, &f.Version, versionFlagName, allFlagName)
 }
 
 func run(
diff --git a/private/buf/cmd/buf/command/config/configlsbreakingrules/usage.gen.go b/private/buf/cmd/buf/command/mod/modlslintrules/usage.gen.go
similarity index 95%
rename from private/buf/cmd/buf/command/config/configlsbreakingrules/usage.gen.go
rename to private/buf/cmd/buf/command/mod/modlslintrules/usage.gen.go
index efd17f37d..c9cd7e215 100644
--- a/private/buf/cmd/buf/command/config/configlsbreakingrules/usage.gen.go
+++ b/private/buf/cmd/buf/command/mod/modlslintrules/usage.gen.go
@@ -14,6 +14,6 @@
 
 // Generated. DO NOT EDIT.
 
-package configlsbreakingrules
+package modlslintrules
 
 import _ "github.com/bufbuild/buf/private/usage"


Test patch:
diff --git a/private/buf/cmd/buf/buf_test.go b/private/buf/cmd/buf/buf_test.go
index a5f5aad8d..8d71fbfa2 100644
--- a/private/buf/cmd/buf/buf_test.go
+++ b/private/buf/cmd/buf/buf_test.go
@@ -546,7 +546,7 @@ PACKAGE_NO_IMPORT_CYCLE                                    Checks that packages
 		nil,
 		0,
 		expectedStdout,
-		"config",
+		"mod",
 		"ls-lint-rules",
 		"--version",
 		"v1",
@@ -564,7 +564,7 @@ func TestCheckLsLintRules2(t *testing.T) {
 		PACKAGE_DIRECTORY_MATCH  MINIMAL, BASIC, DEFAULT, FILE_LAYOUT  Checks that all files are in a directory that matches their package name.
 		ENUM_NO_ALLOW_ALIAS      MINIMAL, BASIC, DEFAULT, SENSIBLE     Checks that enums do not have the allow_alias option set.
 		`,
-		"config",
+		"mod",
 		"ls-lint-rules",
 		"--config",
 		filepath.Join("testdata", "small_list_rules", bufconfig.ExternalConfigV1FilePath),
@@ -622,7 +622,7 @@ ENUM_FIRST_VALUE_ZERO             OTHER                                       Ch
 		nil,
 		0,
 		expectedStdout,
-		"config",
+		"mod",
 		"ls-lint-rules",
 		"--all",
 	)
@@ -695,7 +695,7 @@ FIELD_WIRE_COMPATIBLE_TYPE                      WIRE
 		nil,
 		0,
 		expectedStdout,
-		"config",
+		"mod",
 		"ls-breaking-rules",
 		"--version",
 		"v1",
@@ -713,7 +713,7 @@ func TestCheckLsBreakingRules2(t *testing.T) {
 		ENUM_VALUE_NO_DELETE  FILE, PACKAGE  Checks that enum values are not deleted from a given enum.
 		FIELD_SAME_JSTYPE     FILE, PACKAGE  Checks that fields have the same value for the jstype option.
 		`,
-		"config",
+		"mod",
 		"ls-breaking-rules",
 		"--config",
 		filepath.Join("testdata", "small_list_rules", bufconfig.ExternalConfigV1FilePath),
@@ -731,7 +731,7 @@ func TestCheckLsBreakingRules3(t *testing.T) {
 		ENUM_VALUE_NO_DELETE  FILE, PACKAGE  Checks that enum values are not deleted from a given enum.
 		FIELD_SAME_JSTYPE     FILE, PACKAGE  Checks that fields have the same value for the jstype option.
 		`,
-		"config",
+		"mod",
 		"ls-breaking-rules",
 		"--config",
 		// making sure that .yml works
@@ -804,7 +804,7 @@ FIELD_NO_DELETE_UNLESS_NUMBER_RESERVED          WIRE_JSON, WIRE
 		nil,
 		0,
 		expectedStdout,
-		"config",
+		"mod",
 		"ls-breaking-rules",
 		"--version",
 		"v1beta1",
@@ -1155,9 +1155,9 @@ func TestImageConvertRoundtripJSONBinaryJSON(t *testing.T) {
 	require.Equal(t, json1, stdout.Bytes())
 }
 
-func TestConfigInitBasic(t *testing.T) {
+func TestModInitBasic(t *testing.T) {
 	t.Parallel()
-	testConfigInit(
+	testModInit(
 		t,
 		`version: v1
 breaking:
@@ -1911,7 +1911,7 @@ func testMigrateV1Beta1Diff(
 		0,
 		"",
 		expectedStderr,
-		"config",
+		"beta",
 		"migrate-v1beta1",
 		tempDir,
 	)
@@ -1936,15 +1936,15 @@ func testMigrateV1Beta1Failure(t *testing.T, storageosProvider storageos.Provide
 		1,
 		"",
 		expectedStderr,
-		"config",
+		"beta",
 		"migrate-v1beta1",
 		tempDir,
 	)
 }
 
-func testConfigInit(t *testing.T, expectedData string, document bool, name string, deps ...string) {
+func testModInit(t *testing.T, expectedData string, document bool, name string, deps ...string) {
 	tempDir := t.TempDir()
-	baseArgs := []string{"config", "init"}
+	baseArgs := []string{"mod", "init"}
 	args := append(baseArgs, "-o", tempDir)
 	if document {
 		args = append(args, "--doc")