Skip to content

Commit

Permalink
feat(cli): app subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
moroderNumerous committed Jun 14, 2024
1 parent 4164b01 commit 2ed644e
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 10 deletions.
27 changes: 27 additions & 0 deletions cli/cmd/app/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package app

import (
"os"

"numerous/cli/cmd/app/deploy"

"github.com/spf13/cobra"
)

var AppRootCmd = &cobra.Command{
Use: "app",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
if err := cmd.Help(); err != nil {
return err
}
os.Exit(0)
}

return nil
},
}

func init() {
AppRootCmd.AddCommand(deploy.DeployCmd)
}
2 changes: 1 addition & 1 deletion cli/cmd/deploy/cmd.go → cli/cmd/app/deploy/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ If an app has been initialized in the current working directory, and it should
be pushed to the organization "organization-slug-a3ecfh2b", and the app name
"my-app", the following command can be used:
numerous deploy --organization "organization-slug-a3ecfh2b" --name "my-app"
numerous app deploy --organization "organization-slug-a3ecfh2b" --name "my-app"
`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestDeploy(t *testing.T) {

t.Run("give no existing app then happy path can run", func(t *testing.T) {
appDir := t.TempDir()
copyTo(t, "../../testdata/streamlit_app", appDir)
copyTo(t, "../../../testdata/streamlit_app", appDir)

apps := &mockAppService{}
apps.On("ReadApp", mock.Anything, mock.Anything).Return(app.ReadAppOutput{}, app.ErrAppNotFound)
Expand All @@ -44,7 +44,7 @@ func TestDeploy(t *testing.T) {

t.Run("give existing app then it does not create app", func(t *testing.T) {
appDir := t.TempDir()
copyTo(t, "../../testdata/streamlit_app", appDir)
copyTo(t, "../../../testdata/streamlit_app", appDir)

apps := &mockAppService{}
apps.On("ReadApp", mock.Anything, mock.Anything).Return(app.ReadAppOutput{AppID: appID}, nil)
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions cli/cmd/organization/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package organization
import (
"os"

"numerous/cli/cmd/organization/create"
"numerous/cli/cmd/organization/list"

"github.com/spf13/cobra"
)

Expand All @@ -19,3 +22,8 @@ var OrganizationRootCmd = &cobra.Command{
return nil
},
}

func init() {
OrganizationRootCmd.AddCommand(create.OrganizationCreateCmd)
OrganizationRootCmd.AddCommand(list.OrganizationListCmd)
}
10 changes: 3 additions & 7 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ import (
"runtime"

"numerous/cli/auth"
"numerous/cli/cmd/app"
deleteapp "numerous/cli/cmd/delete"
"numerous/cli/cmd/deploy"
"numerous/cli/cmd/dev"
"numerous/cli/cmd/initialize"
"numerous/cli/cmd/list"
"numerous/cli/cmd/log"
"numerous/cli/cmd/login"
"numerous/cli/cmd/logout"
"numerous/cli/cmd/organization"
createorganization "numerous/cli/cmd/organization/create"
listorganization "numerous/cli/cmd/organization/list"
"numerous/cli/cmd/publish"
"numerous/cli/cmd/push"
"numerous/cli/cmd/report"
Expand Down Expand Up @@ -93,7 +91,7 @@ func commandRequiresAuthentication(invokedCommandName string) bool {
"numerous log",
"numerous organization create",
"numerous organization list",
"numerous deploy",
"numerous app deploy",
}

for _, cmd := range commandsWithAuthRequired {
Expand All @@ -118,9 +116,7 @@ func bindCommands() {
rootCmd.AddCommand(list.ListCmd)
rootCmd.AddCommand(report.ReportCmd)
rootCmd.AddCommand(organization.OrganizationRootCmd)
rootCmd.AddCommand(deploy.DeployCmd)
organization.OrganizationRootCmd.AddCommand(createorganization.OrganizationCreateCmd)
organization.OrganizationRootCmd.AddCommand(listorganization.OrganizationListCmd)
rootCmd.AddCommand(app.AppRootCmd)
}

func Execute() {
Expand Down

0 comments on commit 2ed644e

Please sign in to comment.