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

[ocu-472] basic smithyctl boilerplate + small fixes #707

Merged
24 changes: 24 additions & 0 deletions smithyctl/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"log"

"github.com/smithy-security/smithyctl/command/build"
"github.com/smithy-security/smithyctl/command/packaging"
"github.com/smithy-security/smithyctl/command/version"
"github.com/smithy-security/smithyctl/command/workflow"
"github.com/smithy-security/smithyctl/internal/command"
)

func main() {
if err := command.
NewRootCommand(
version.NewCommand(),
build.NewCommand(),
packaging.NewCommand(),
workflow.NewCommand(),
).
Execute(); err != nil {
log.Fatalf("could not execute smithyctl: %v", err)
}
}
15 changes: 15 additions & 0 deletions smithyctl/command/build/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package build

import "github.com/spf13/cobra"

// NewCommand returns a new build command.
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "build",
Short: "Builds a component's container",
// TODO: implement in https://linear.app/smithy/issue/OCU-471/build-components
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
}
}
17 changes: 17 additions & 0 deletions smithyctl/command/packaging/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package packaging

import (
"github.com/spf13/cobra"
)

// NewCommand returns a new package command.
func NewCommand() *cobra.Command {
// TODO: implement in https://linear.app/smithy/issue/OCU-473/package-components-using-oras
return &cobra.Command{
Use: "package",
Short: "Packages a component's configuration",
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
}
}
15 changes: 15 additions & 0 deletions smithyctl/command/version/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package version

import "github.com/spf13/cobra"

// NewCommand returns a new version command.
func NewCommand() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Outputs smithyctl's version",
// TODO: implement in https://linear.app/smithy/issue/OCU-481/version-command
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
}
}
16 changes: 16 additions & 0 deletions smithyctl/command/workflow/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package workflow

import "github.com/spf13/cobra"

// NewCommand returns a new workflow command.
func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "workflow",
Short: "Allows interacting with workflows",
// TODO: implement in https://linear.app/smithy/issue/OCU-476/run-workflows-locally
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
}
return cmd
}
19 changes: 19 additions & 0 deletions smithyctl/internal/command/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package command
andream16 marked this conversation as resolved.
Show resolved Hide resolved

import (
"github.com/spf13/cobra"
)

// NewRootCommand register all the subcommands into the same root command.
func NewRootCommand(commands ...*cobra.Command) *cobra.Command {
rootCmd := &cobra.Command{
Use: "smithyctl",
Short: "A CLI app for managing components and workflows",
}

for _, cmd := range commands {
rootCmd.AddCommand(cmd)
}

return rootCmd
}