mirror of
https://github.com/foomo/posh.git
synced 2025-10-16 12:45:38 +00:00
41 lines
1003 B
Go
41 lines
1003 B
Go
package cmd
|
|
|
|
import (
|
|
"github.com/foomo/posh/internal/util"
|
|
"github.com/pkg/errors"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// execCmd represents the exec command
|
|
var execCmd = &cobra.Command{
|
|
Use: "exec",
|
|
Short: "Execute a single Project Oriented Shell command",
|
|
Args: cobra.ArbitraryArgs,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
if len(args) == 0 {
|
|
return errors.New("missing [cmd] argument")
|
|
}
|
|
|
|
plg, err := util.LoadPlugin(cmd.Context(), m)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return plg.Execute(cmd.Context(), args)
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(execCmd)
|
|
|
|
// Here you will define your flags and configuration settings.
|
|
|
|
// Cobra supports Persistent Flags which will work for this command
|
|
// and all subcommands, e.g.:
|
|
// execCmd.PersistentFlags().String("foo", "", "A help for foo")
|
|
|
|
// Cobra supports local flags which will only run when this command
|
|
// is called directly, e.g.:
|
|
// execCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
}
|