diff --git a/cmd/conduit/root/docs/docs.go b/cmd/conduit/root/docs/docs.go new file mode 100644 index 000000000..75db4dd26 --- /dev/null +++ b/cmd/conduit/root/docs/docs.go @@ -0,0 +1,30 @@ +// Copyright © 2025 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 docs + +import ( + "github.com/conduitio/conduit/cmd/conduit/root/open" + "github.com/conduitio/ecdysis" +) + +var _ ecdysis.CommandWithHidden = (*DocsCommand)(nil) + +type DocsCommand struct { + open.DocsCommand +} + +func (d *DocsCommand) Hidden() bool { + return true +} diff --git a/cmd/conduit/root/open/docs.go b/cmd/conduit/root/open/docs.go new file mode 100644 index 000000000..76cad8156 --- /dev/null +++ b/cmd/conduit/root/open/docs.go @@ -0,0 +1,46 @@ +// Copyright © 2025 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 open + +import ( + "context" + + "github.com/conduitio/ecdysis" + "github.com/pkg/browser" +) + +const ConduitDocsURL = "https://conduit.io/docs" + +var ( + _ ecdysis.CommandWithDocs = (*DocsCommand)(nil) + _ ecdysis.CommandWithExecute = (*DocsCommand)(nil) + _ ecdysis.CommandWithAliases = (*DocsCommand)(nil) +) + +type DocsCommand struct{} + +func (c *DocsCommand) Aliases() []string { return []string{"documentation", "docs"} } + +func (c *DocsCommand) Execute(_ context.Context) error { + return browser.OpenURL(ConduitDocsURL) +} + +func (c *DocsCommand) Usage() string { return "docs" } + +func (c *DocsCommand) Docs() ecdysis.Docs { + return ecdysis.Docs{ + Short: "Open Conduit documentation in a web browser", + } +} diff --git a/cmd/conduit/root/open/open.go b/cmd/conduit/root/open/open.go new file mode 100644 index 000000000..855c39cb9 --- /dev/null +++ b/cmd/conduit/root/open/open.go @@ -0,0 +1,40 @@ +// Copyright © 2025 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 open + +import ( + "github.com/conduitio/ecdysis" +) + +var ( + _ ecdysis.CommandWithDocs = (*OpenCommand)(nil) + _ ecdysis.CommandWithSubCommands = (*OpenCommand)(nil) +) + +type OpenCommand struct{} + +func (c *OpenCommand) Usage() string { return "open" } + +func (c *OpenCommand) Docs() ecdysis.Docs { + return ecdysis.Docs{ + Short: "Open in a web browser", + } +} + +func (c *OpenCommand) SubCommands() []ecdysis.Command { + return []ecdysis.Command{ + &DocsCommand{}, + } +} diff --git a/cmd/conduit/root/root.go b/cmd/conduit/root/root.go index b1869b891..0786eb4d7 100644 --- a/cmd/conduit/root/root.go +++ b/cmd/conduit/root/root.go @@ -22,7 +22,9 @@ import ( "github.com/conduitio/conduit/cmd/conduit/root/config" "github.com/conduitio/conduit/cmd/conduit/root/connectorplugins" "github.com/conduitio/conduit/cmd/conduit/root/connectors" + "github.com/conduitio/conduit/cmd/conduit/root/docs" "github.com/conduitio/conduit/cmd/conduit/root/initialize" + "github.com/conduitio/conduit/cmd/conduit/root/open" "github.com/conduitio/conduit/cmd/conduit/root/pipelines" "github.com/conduitio/conduit/cmd/conduit/root/processorplugins" "github.com/conduitio/conduit/cmd/conduit/root/processors" @@ -84,7 +86,9 @@ func (c *RootCommand) SubCommands() []ecdysis.Command { &config.ConfigCommand{RunCmd: runCmd}, &connectors.ConnectorsCommand{}, &connectorplugins.ConnectorPluginsCommand{}, + &docs.DocsCommand{}, &initialize.InitCommand{Cfg: &runCmd.Cfg}, + &open.OpenCommand{}, &pipelines.PipelinesCommand{}, &processors.ProcessorsCommand{}, &processorplugins.ProcessorPluginsCommand{}, diff --git a/go.mod b/go.mod index 76e4955e0..291bddcff 100644 --- a/go.mod +++ b/go.mod @@ -36,6 +36,7 @@ require ( github.com/matryer/is v1.4.1 github.com/neilotoole/slogt v1.1.0 github.com/piotrkowalczuk/promgrpc/v4 v4.1.4 + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c github.com/prometheus/client_golang v1.20.5 github.com/prometheus/client_model v0.6.1 github.com/prometheus/common v0.62.0 @@ -286,7 +287,6 @@ require ( github.com/opencontainers/runtime-spec v1.2.0 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/pierrec/lz4/v4 v4.1.21 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pkg/profile v1.7.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect