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

swctl : Implement swctl dependency commands #115

Merged
merged 8 commits into from
Sep 11, 2023
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
10 changes: 9 additions & 1 deletion cmd/swctl/app/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Cli interface {
Entities() []Entity
GlobalOptions() *GlobalOptions
Exec(cmd string, args []string) (stdout string, stderr string, err error)
AppName() string

Out() *streams.Out
Err() io.Writer
Expand All @@ -42,14 +43,17 @@ type CLI struct {
out *streams.Out
err io.Writer
in *streams.In

appName string
}

// NewCli returns a new CLI instance. It accepts CliOption for customization.
func NewCli(opt ...CliOption) (*CLI, error) {
func NewCli(appName string, opt ...CliOption) (*CLI, error) {
cli := new(CLI)
if err := cli.Apply(opt...); err != nil {
return nil, err
}
cli.appName = appName
if cli.out == nil || cli.in == nil || cli.err == nil {
stdin, stdout, stderr := term.StdStreams()
if cli.in == nil {
Expand Down Expand Up @@ -166,3 +170,7 @@ func (cli *CLI) Err() io.Writer {
func (cli *CLI) In() *streams.In {
return cli.in
}

func (cli *CLI) AppName() string {
return cli.appName
}
3 changes: 3 additions & 0 deletions cmd/swctl/app/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"fmt"

"github.com/gookit/color"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -24,6 +25,7 @@ func NewRootCmd(cli Cli) *cobra.Command {
var (
glob GlobalOptions
)

cmd := &cobra.Command{
Use: "swctl [options] [command]",
Short: "swctl is CLI tool to manage StoneWork and its components",
Expand Down Expand Up @@ -64,6 +66,7 @@ func NewRootCmd(cli Cli) *cobra.Command {
NewTraceCmd(cli),
NewSupportCmd(cli),
NewManageCmd(cli),
NewDependencyCmd(cli),
)

cmd.InitDefaultHelpCmd()
Expand Down
Loading