Skip to content

Commit

Permalink
Merge pull request #48 from CircleCI-Public/glob
Browse files Browse the repository at this point in the history
Add `circleci tests glob` for backwards compatibility
  • Loading branch information
Zachary Scott authored Aug 7, 2018
2 parents 4e1aec4 + 43cd901 commit 88db083
Show file tree
Hide file tree
Showing 12 changed files with 583 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func MakeCommands() *cobra.Command {
cobra.AddTemplateFunc("HasAnnotations", hasAnnotations)
rootCmd.SetUsageTemplate(usageTemplate)

rootCmd.AddCommand(newTestsCommand())
rootCmd.AddCommand(newQueryCommand())
rootCmd.AddCommand(newConfigCommand())
rootCmd.AddCommand(newOrbCommand())
Expand Down
2 changes: 1 addition & 1 deletion cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var _ = Describe("Root", func() {

It("can create commands", func() {
commands := cmd.MakeCommands()
Expect(len(commands.Commands())).To(Equal(10))
Expect(len(commands.Commands())).To(Equal(11))
})

})
Expand Down
56 changes: 56 additions & 0 deletions cmd/tests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package cmd

import (
"fmt"
"os"

"github.com/bmatcuk/doublestar"
"github.com/spf13/cobra"
)

func newTestsCommand() *cobra.Command {
testsCmd := &cobra.Command{
Use: "tests",
Short: "Collect and split files with tests",
Hidden: true,
}

globCmd := &cobra.Command{
Use: "glob",
Short: "glob files using pattern",
Run: globRun,
Hidden: true,
}

testsCmd.AddCommand(globCmd)

return testsCmd
}

func expandGlobs(args []string) ([]string, error) {
result := []string{}

for _, arg := range args {
matches, err := doublestar.Glob(arg)
if err != nil {
return nil, err
}

result = append(result, matches...)
}

return result, nil
}

func globRun(cmd *cobra.Command, args []string) {
allfiles, err := expandGlobs(args)

if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}

for _, filename := range allfiles {
fmt.Println(filename)
}
}
29 changes: 29 additions & 0 deletions vendor/github.com/bmatcuk/doublestar/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/bmatcuk/doublestar/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/github.com/bmatcuk/doublestar/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions vendor/github.com/bmatcuk/doublestar/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 88db083

Please sign in to comment.