Skip to content

Commit

Permalink
Merge pull request choria-io#1690 from ripienaar/1665.15
Browse files Browse the repository at this point in the history
(choria-io#1665) expose the appbuilder cli
  • Loading branch information
ripienaar authored May 25, 2022
2 parents d77102c + 0d40baa commit 656a1a4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 13 deletions.
11 changes: 6 additions & 5 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,22 @@ func ParseCLI() (err error) {
return
}

func builderOptions() []builder.Option {
return []builder.Option{builder.WithConfigPaths(".", filepath.Join(xdg.ConfigHome, "choria", "builder"), filepath.Join("/", "etc", "choria", "builder"))}
}

func runBuilder() {
kv.MustRegister()
rpc.MustRegister()
discover.MustRegister()
parent.MustRegister()
exec.MustRegister()

logger := log.New()
logger.SetLevel(log.WarnLevel)
err := builder.RunStandardCLI(ctx, filepath.Base(os.Args[0]), false, log.NewEntry(logger),
builder.WithLogger(log.NewEntry(logger)),
builder.WithConfigPaths(".", filepath.Join(xdg.ConfigHome, "choria", "builder"), filepath.Join("etc", "choria", "builder")))
err := builder.RunStandardCLI(ctx, filepath.Base(os.Args[0]), false, nil, builderOptions()...)
if err != nil {
panic(fmt.Sprintf("app builder setup failed: %v", err))
}

os.Exit(0)
}

Expand Down
45 changes: 45 additions & 0 deletions cmd/tool_builder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2022, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
"sync"

"github.com/choria-io/appbuilder/builder"
)

type tBuilderCommand struct {
command
}

func (c *tBuilderCommand) Setup() error {
if tool, ok := cmdWithFullCommand("tool"); ok {
c.cmd = tool.Cmd().Command("builder", "Application Builder tools")
bldr, err := builder.New(ctx, "builder", builderOptions()...)
if err != nil {
return err
}

// builder cli is Action() based
ran = true

bldr.CreateBuilderApp(c.cmd)
}

return nil
}

func (c *tBuilderCommand) Configure() error {
return nil
}

func (c *tBuilderCommand) Run(wg *sync.WaitGroup) error {
wg.Done()
return nil
}

func init() {
cli.commands = append(cli.commands, &tBuilderCommand{})
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/antonmedv/expr v1.9.0
github.com/awesome-gocui/gocui v1.1.0
github.com/brutella/hc v1.2.5
github.com/choria-io/appbuilder v0.0.4
github.com/choria-io/appbuilder v0.0.5
github.com/cloudevents/sdk-go/v2 v2.10.0
github.com/fatih/color v1.13.0
github.com/ghodss/yaml v1.0.0
Expand All @@ -29,8 +29,8 @@ require (
github.com/miekg/pkcs11 v1.1.1
github.com/mitchellh/mapstructure v1.5.0
github.com/nats-io/jsm.go v0.0.32-0.20220520130442-4fcfcb01e3a5
github.com/nats-io/nats-server/v2 v2.8.3
github.com/nats-io/nats.go v1.15.1-0.20220510154044-144a3b25a04c
github.com/nats-io/nats-server/v2 v2.8.4-0.20220524225320-752c0adec50d
github.com/nats-io/nats.go v1.15.1-0.20220525015314-4e4f31855ccb
github.com/nats-io/natscli v0.0.33-0.20220523083704-8df8a5abe5b6
github.com/olekukonko/tablewriter v0.0.5
github.com/onsi/ginkgo/v2 v2.1.4
Expand Down
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d8
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE=
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
github.com/choria-io/appbuilder v0.0.4 h1:u6RkHgSJlnNhnqoWbqXZUY//8L1XCNbREPU5uDn/DA0=
github.com/choria-io/appbuilder v0.0.4/go.mod h1:1S3nj4fALNNpkrmB7vPLCf5L9khohm8H/JD05OXrUZk=
github.com/choria-io/appbuilder v0.0.5 h1:zek4sSMfVv1gNNy5FKwFXCIao5r15ExqO0DTzb1pOG8=
github.com/choria-io/appbuilder v0.0.5/go.mod h1:O8B23N32wXfk7dvgslAkedrjjRE6nDeXpBT1ByUtYFg=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down Expand Up @@ -816,12 +816,13 @@ github.com/nats-io/jsm.go v0.0.32-0.20220520130442-4fcfcb01e3a5/go.mod h1:DjZyMf
github.com/nats-io/jwt/v2 v2.2.1-0.20220330180145-442af02fd36a h1:lem6QCvxR0Y28gth9P+wV2K/zYUUAkJ+55U8cpS0p5I=
github.com/nats-io/jwt/v2 v2.2.1-0.20220330180145-442af02fd36a/go.mod h1:0tqz9Hlu6bCBFLWAASKhE5vUA4c24L9KPUUgvwumE/k=
github.com/nats-io/nats-server/v2 v2.8.3-0.20220519223628-114474562cc3/go.mod h1:vIdpKz3OG+DCg4q/xVPdXHoztEyKDWRtykQ4N7hd7C4=
github.com/nats-io/nats-server/v2 v2.8.3 h1:5jCAOZ62OeL0YSVhMotP17zk4K/N5bAHGwxyIGspjM8=
github.com/nats-io/nats-server/v2 v2.8.3/go.mod h1:8zZa+Al3WsESfmgSs98Fi06dRWLH5Bnq90m5bKD/eT4=
github.com/nats-io/nats-server/v2 v2.8.4-0.20220524225320-752c0adec50d h1:tSc2SvfJE24lwT5750qLG3sW0ZkVhK1BjFlv7IfO1SY=
github.com/nats-io/nats-server/v2 v2.8.4-0.20220524225320-752c0adec50d/go.mod h1:8zZa+Al3WsESfmgSs98Fi06dRWLH5Bnq90m5bKD/eT4=
github.com/nats-io/nats.go v1.14.0/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w=
github.com/nats-io/nats.go v1.15.0/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w=
github.com/nats-io/nats.go v1.15.1-0.20220510154044-144a3b25a04c h1:wPyQ9Hio2+avPADhjg2mE6TImroo7HcXk1b8NOUdwO0=
github.com/nats-io/nats.go v1.15.1-0.20220510154044-144a3b25a04c/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w=
github.com/nats-io/nats.go v1.15.1-0.20220525015314-4e4f31855ccb h1:6/+NEcBBqCBMjE2brz5S+TdlQS/7fwOUdHmA5aJP/88=
github.com/nats-io/nats.go v1.15.1-0.20220525015314-4e4f31855ccb/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w=
github.com/nats-io/natscli v0.0.33-0.20220523083704-8df8a5abe5b6 h1:R8PS/le5CxJWXnS0M1ZfsIBaZLKK3w+pD6KBmN2RlUQ=
github.com/nats-io/natscli v0.0.33-0.20220523083704-8df8a5abe5b6/go.mod h1:nglygaR6VecwiLxpB7dzZkSQg2tRcc6Se2n4zcLpKTQ=
github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8=
Expand Down

0 comments on commit 656a1a4

Please sign in to comment.