Skip to content

Commit

Permalink
feat: add conduit version (#2035)
Browse files Browse the repository at this point in the history
* feat: add conduit version

* move version into its own pkg
  • Loading branch information
raulb authored Dec 20, 2024
1 parent 1eb87ce commit 3268d78
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cmd/conduit/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"path/filepath"

"github.com/conduitio/conduit/cmd/conduit/root/pipelines"
"github.com/conduitio/conduit/cmd/conduit/root/version"
"github.com/conduitio/conduit/pkg/conduit"
"github.com/conduitio/conduit/pkg/foundation/cerrors"
"github.com/conduitio/ecdysis"
Expand All @@ -35,7 +36,7 @@ var (
)

type RootFlags struct {
Version bool `long:"version" short:"v" usage:"show current Conduit version" persistent:"true"`
Version bool `long:"version" short:"v" usage:"show the current Conduit version"`
conduit.Config
}

Expand Down Expand Up @@ -113,10 +114,9 @@ func (c *RootCommand) Docs() ecdysis.Docs {

func (c *RootCommand) SubCommands() []ecdysis.Command {
return []ecdysis.Command{
&ConfigCommand{
rootCmd: c,
},
&ConfigCommand{rootCmd: c},
&InitCommand{cfg: &c.cfg},
&version.VersionCommand{},
&pipelines.PipelinesCommand{},
}
}
2 changes: 1 addition & 1 deletion cmd/conduit/root/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestRootCommandFlags(t *testing.T) {
persistent bool
}{
{longName: "config.path", usage: "global conduit configuration file"},
{longName: "version", shortName: "v", usage: "show current Conduit version", persistent: true},
{longName: "version", shortName: "v", usage: "show the current Conduit version"},
{longName: "db.type", usage: "database type; accepts badger,postgres,inmemory,sqlite"},
{longName: "db.badger.path", usage: "path to badger DB"},
{longName: "db.postgres.connection-string", usage: "postgres connection string, may be a database URL or in PostgreSQL keyword/value format"},
Expand Down
44 changes: 44 additions & 0 deletions cmd/conduit/root/version/version.go
Original file line number Diff line number Diff line change
@@ -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.",
}
}

0 comments on commit 3268d78

Please sign in to comment.