mirror of
https://github.com/foomo/posh.git
synced 2025-10-16 12:45:38 +00:00
35 lines
764 B
Go
35 lines
764 B
Go
package cmd
|
|
|
|
import (
|
|
intconfig "github.com/foomo/posh/internal/config"
|
|
"github.com/pkg/errors"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// execCmd represents the exec command
|
|
var execCmd = &cobra.Command{
|
|
Use: "execute",
|
|
Short: "Execute a single Project Oriented Shell command",
|
|
Args: cobra.ArbitraryArgs,
|
|
SilenceUsage: true,
|
|
SilenceErrors: true,
|
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
|
if err := intconfig.Load(l); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
},
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
if len(args) == 0 {
|
|
return errors.New("missing [cmd] argument")
|
|
}
|
|
|
|
plg, err := pluginProvider(l)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return plg.Execute(cmd.Context(), args)
|
|
},
|
|
}
|