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

feat: add conduit version #2035

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.",
}
}
Loading