github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/command/plugin_builtin.go (about)

     1  package command
     2  
     3  import (
     4  	"os"
     5  	"strings"
     6  
     7  	"github.com/hashicorp/otto/plugin"
     8  )
     9  
    10  // PluginBuiltinCommand is a command for serving our internal plugins.
    11  // This is not a command we expect users to call directly.
    12  type PluginBuiltinCommand struct {
    13  	Meta
    14  }
    15  
    16  func (c *PluginBuiltinCommand) Run(args []string) int {
    17  	os.Args = append([]string{"self"}, args...)
    18  	plugin.ServeMux(c.PluginMap)
    19  	return 0
    20  }
    21  
    22  func (c *PluginBuiltinCommand) Synopsis() string {
    23  	return "Runs a built-in plugin"
    24  }
    25  
    26  func (c *PluginBuiltinCommand) Help() string {
    27  	helpText := `
    28  Usage: otto plugin-builtin TYPE NAME
    29  
    30    Runs a built-in plugin.
    31  
    32    This is an internal command that shouldn't be called directly.
    33  
    34  `
    35  
    36  	return strings.TrimSpace(helpText)
    37  }