diff --git a/cmd/conduit/root/root.go b/cmd/conduit/root/root.go index 80f0be4b1..8f1e9e498 100644 --- a/cmd/conduit/root/root.go +++ b/cmd/conduit/root/root.go @@ -22,7 +22,7 @@ import ( "github.com/conduitio/conduit/cmd/conduit/root/config" "github.com/conduitio/conduit/cmd/conduit/root/initialize" "github.com/conduitio/conduit/cmd/conduit/root/pipelines" - "github.com/conduitio/conduit/cmd/conduit/root/run" + "github.com/conduitio/conduit/cmd/conduit/root/version" "github.com/conduitio/conduit/pkg/conduit" "github.com/conduitio/ecdysis" ) @@ -35,7 +35,8 @@ var ( ) type RootFlags struct { - Version bool `long:"version" short:"v" usage:"show current Conduit version"` + Version bool `long:"version" short:"v" usage:"show the current Conduit version"` + conduit.Config } type RootCommand struct { @@ -74,6 +75,7 @@ func (c *RootCommand) SubCommands() []ecdysis.Command { return []ecdysis.Command{ &config.ConfigCommand{RunCmd: runCmd}, &initialize.InitCommand{Cfg: &runCmd.Cfg}, + &version.VersionCommand{}, &pipelines.PipelinesCommand{}, &run.RunCommand{}, } diff --git a/cmd/conduit/root/version/version.go b/cmd/conduit/root/version/version.go new file mode 100644 index 000000000..669113146 --- /dev/null +++ b/cmd/conduit/root/version/version.go @@ -0,0 +1,44 @@ +// Copyright © 2024 Meroxa, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package version + +import ( + "context" + "fmt" + "os" + + "github.com/conduitio/conduit/pkg/conduit" + "github.com/conduitio/ecdysis" +) + +var ( + _ ecdysis.CommandWithExecute = (*VersionCommand)(nil) + _ ecdysis.CommandWithDocs = (*VersionCommand)(nil) +) + +type VersionCommand struct{} + +func (c *VersionCommand) Usage() string { return "version" } + +func (c *VersionCommand) Execute(_ context.Context) error { + _, _ = fmt.Fprintf(os.Stdout, "%s\n", conduit.Version(true)) + return nil +} + +func (c *VersionCommand) Docs() ecdysis.Docs { + return ecdysis.Docs{ + Short: "Show the current version of Conduit.", + } +}