Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Move all the commands to their own package internal/commands so they …
Browse files Browse the repository at this point in the history
…can be re-used by another binary.

Signed-off-by: Silvin Lubecki <[email protected]>
  • Loading branch information
silvin-lubecki committed Feb 28, 2019
1 parent 6c0aea5 commit 625befd
Show file tree
Hide file tree
Showing 21 changed files with 25 additions and 26 deletions.
3 changes: 2 additions & 1 deletion cmd/docker-app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"github.com/docker/app/internal"
app "github.com/docker/app/internal/commands"
"github.com/docker/cli/cli-plugins/manager"
"github.com/docker/cli/cli-plugins/plugin"
"github.com/docker/cli/cli/command"
Expand All @@ -10,7 +11,7 @@ import (

func main() {
plugin.Run(func(dockerCli command.Cli) *cobra.Command {
return newRootCmd(dockerCli)
return app.NewRootCmd("app", dockerCli)
}, manager.Metadata{
SchemaVersion: "0.1.0",
Vendor: "Docker Inc.",
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/bundle.go → internal/commands/bundle.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/cnab.go → internal/commands/cnab.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/init.go → internal/commands/init.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"github.com/docker/app/internal/packager"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/inspect.go → internal/commands/inspect.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"github.com/deislabs/duffle/pkg/action"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/install.go → internal/commands/install.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/merge.go → internal/commands/merge.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/pull.go → internal/commands/pull.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"github.com/docker/app/internal/packager"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/push.go → internal/commands/push.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/render.go → internal/commands/render.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
10 changes: 4 additions & 6 deletions cmd/docker-app/root.go → internal/commands/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"io/ioutil"
Expand All @@ -9,19 +9,17 @@ import (
"github.com/spf13/pflag"
)

// rootCmd represents the base command when called without any subcommands
// FIXME(vdemeester) use command.Cli interface
func newRootCmd(dockerCli command.Cli) *cobra.Command {
// NewRootCmd returns the base root command.
func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
cmd := &cobra.Command{
Use: "app",
Short: "Docker Application Packages",
Long: `Build and deploy Docker Application Packages.`,
Use: use,
}
addCommands(cmd, dockerCli)
return cmd
}

// addCommands adds all the commands from cli/command to the root command
func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
cmd.AddCommand(
installCmd(dockerCli),
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/split.go → internal/commands/split.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"github.com/docker/app/internal/packager"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/status.go → internal/commands/status.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"github.com/deislabs/duffle/pkg/action"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/upgrade.go → internal/commands/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"github.com/docker/app/internal/packager"
Expand Down
2 changes: 1 addition & 1 deletion cmd/docker-app/version.go → internal/commands/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package commands

import (
"fmt"
Expand Down

0 comments on commit 625befd

Please sign in to comment.