Skip to content

Commit

Permalink
Add projects even if they are hidden
Browse files Browse the repository at this point in the history
And have cobra hide them. For projects that are a set of dependencies
that are shared by multiple projects, you might want to hide the project
but still act on the project which this change will allow.
  • Loading branch information
svrana committed Jun 12, 2019
1 parent 35262e7 commit 6b7cab5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,13 @@ use more one docker-compose.yml file.`,
}

func addProjects(cmd *cobra.Command, config *config.Dev) error {
for _, projectConfig := range config.RunnableProjects() {
for _, projectConfig := range config.Projects {
log.Debugf("Adding %s to project commands, aliases: %s", projectConfig.Name, projectConfig.Aliases)
cmd := &cobra.Command{
Use: projectConfig.Name,
Short: "Run dev commands on the " + projectConfig.Name + " project",
Aliases: projectConfig.Aliases,
Hidden: projectConfig.Hidden,
}
rootCmd.AddCommand(cmd)

Expand Down
13 changes: 0 additions & 13 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,6 @@ func NewConfig() *Dev {
return config
}

// RunnableProjects returns the Project configuration of each Project
// that has a docker-compose.yml file and is not hidden by configuration.
func (c *Dev) RunnableProjects() []*Project {
var projects []*Project

for _, project := range c.Projects {
if len(project.DockerComposeFilenames) > 0 && !project.Hidden {
projects = append(projects, project)
}
}
return projects
}

func pathToDockerComposeFilenames(directory string) []string {
paths := make([]string, len(dockerComposeFilenames))
for _, filename := range dockerComposeFilenames {
Expand Down

0 comments on commit 6b7cab5

Please sign in to comment.