diff --git a/api/api.go b/api/api.go index a21cb40e8..49a2d97ce 100644 --- a/api/api.go +++ b/api/api.go @@ -3,6 +3,7 @@ package api import ( "context" "io/ioutil" + "os" "strings" "github.com/CircleCI-Public/circleci-cli/client" @@ -36,8 +37,13 @@ func (response ConfigResponse) ToError() error { } func loadYaml(path string) (string, error) { - - config, err := ioutil.ReadFile(path) + var err error + var config []byte + if path == "-" { + config, err = ioutil.ReadAll(os.Stdin) + } else { + config, err = ioutil.ReadFile(path) + } if err != nil { return "", errors.Wrapf(err, "Could not load config file at %s", path) diff --git a/cmd/orb.go b/cmd/orb.go index 89ff9e0ca..7797ba858 100644 --- a/cmd/orb.go +++ b/cmd/orb.go @@ -41,10 +41,10 @@ func newOrbCommand() *cobra.Command { orbCommand.AddCommand(orbListCommand) - orbValidateCommand.PersistentFlags().StringVarP(&orbPath, "path", "p", "orb.yml", "path to orb file") + orbValidateCommand.PersistentFlags().StringVarP(&orbPath, "path", "p", "orb.yml", "path to orb file ('-' for STDIN)") orbCommand.AddCommand(orbValidateCommand) - orbExpandCommand.PersistentFlags().StringVarP(&orbPath, "path", "p", "orb.yml", "path to orb file") + orbExpandCommand.PersistentFlags().StringVarP(&orbPath, "path", "p", "orb.yml", "path to orb file ('-' for STDIN)") orbCommand.AddCommand(orbExpandCommand) return orbCommand diff --git a/cmd/root.go b/cmd/root.go index 64b9f0b52..4f3727a34 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -50,7 +50,7 @@ func MakeCommands() *cobra.Command { rootCmd.PersistentFlags().BoolP("verbose", "v", false, "Enable verbose logging.") rootCmd.PersistentFlags().StringP("endpoint", "e", defaultEndpoint, "the endpoint of your CircleCI GraphQL API") rootCmd.PersistentFlags().StringP("token", "t", "", "your token for using CircleCI") - rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", configPath, "path to build config") + rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", configPath, "path to build config. '-' reads from STDIN") for _, flag := range []string{"endpoint", "token", "verbose"} { bindCobraFlagToViper(rootCmd, flag)