// RunSource executes the command passed as argument,
// in the current shell/context
507045
func RunSource(cmd *exec.Cmd) error {
	cmd.Stdin = os.Stdin
	cmd.Stderr = os.Stderr
	cmd.Stdout = os.Stdout
	return cmd.Run()
}
33630
func (c *ListCharmResourcesCommand) Run(ctx *cmd.Context) error {
	ctx.Warningf(DeprecatedSince)
	return c.baseRun(ctx)
}
551828
func (c *Client) CreateSource(ctx context.Context, s *platform.Source) error {
	err := c.db.Update(func(tx *bolt.Tx) error {
		s.ID = c.IDGenerator.ID()

		// Generating an organization id if it missing or invalid
		if !s.OrganizationID.Valid() {
			s.OrganizationID = c.IDGenerator.ID()
		}

		return c.putSource(ctx, tx, s)
	})
	if err != nil {
		return &platform.Error{
			Err: err,
			Op:  getOp(platform.OpCreateSource),
		}
	}
	return nil
}
141534
func (h *Client) CampaignSource(campaignSource string) *Client {
	h.campaignSource = campaignSource
	h.campaignSourceSet = true
	return h
}
1332710
func (e *Error) ContextSource() []SourceLine {
	if e.SourceLines == nil {
		return nil
	}
	start := (e.Line - 1) - 5
	if start < 0 {
		start = 0
	}
	end := (e.Line - 1) + 5
	if end > len(e.SourceLines) {
		end = len(e.SourceLines)
	}

	lines := make([]SourceLine, end-start)
	for i, src := range e.SourceLines[start:end] {
		fileLine := start + i + 1
		lines[i] = SourceLine{src, fileLine, fileLine == e.Line}
	}
	return lines
}
608490
func (s *Service) PutSource(ctx context.Context, src *platform.Source) error {
	s.sourceKV.Store(src.ID.String(), src)
	return nil
}
631063
func (p *Pipeline) SetSource(s Source) {
	p.mutex.Lock()
	defer p.mutex.Unlock()

	p.src = s
}
428626
func (runner *runner) RunCommands(commands string) (*utilexec.ExecResponse, error) {
	result, err := runner.runCommandsWithTimeout(commands, 0, clock.WallClock)
	return result, runner.context.Flush("run commands", err)
}
184887
func runServer(ctx context.Context, cmd *command.Command, args []string, store storage.Store, chanSize, bulkSize int) int {
	// Check parameters.
	if len(args) < 2 {
		log.Printf("[%v] Missing required port number. ", time.Now())
		cmd.Usage()
		return 2
	}

	// Validate port number.
	p := strings.TrimSpace(args[len(args)-1])
	port, err := strconv.Atoi(p)
	if err != nil {
		log.Printf("[%v] Invalid port number %q; %v\n", time.Now(), p, err)
		return 2
	}

	// Start the server.
	log.Printf("[%v] Starting server at port %d\n", time.Now(), port)
	s := &serverConfig{
		store:    store,
		chanSize: chanSize,
		bulkSize: bulkSize,
	}
	http.HandleFunc("/bql", s.bqlHandler)
	http.HandleFunc("/", defaultHandler)
	if err := http.ListenAndServe(":"+p, nil); err != nil {
		log.Printf("[%v] Failed to start server on port %s; %v", time.Now(), p, err)
		return 2
	}
	return 0
}
542882
func RunCommand(name string, arg ...string) error {
	cmd := exec.Command(name, arg...)
	cmdStr := strings.Join(cmd.Args, " ")
	log.Info(cmdStr)
	_, err := cmd.Output()
	if err != nil {
		if exErr, ok := err.(*exec.ExitError); ok {
			errOutput := string(exErr.Stderr)
			log.Errorf("`%s` failed: %s", cmdStr, errOutput)
			return errors.InternalError(strings.TrimSpace(errOutput))
		}
		return errors.InternalWrapError(err)
	}
	return nil
}
28769
func NewSource(ctx *Context, stmt *rel.SqlSource, isFinal bool) (*Source, error) {
	s := &Source{Stmt: stmt, ctx: ctx, SourcePb: &SourcePb{Final: isFinal}, PlanBase: NewPlanBase(false)}
	err := s.load()
	if err != nil {
		return nil, err
	}
	return s, nil
}
65703
func RunCommand(fs *flag.FlagSet, cmd *Command, projectroot, goroot string, args []string) error {
	if cmd.AddFlags != nil {
		cmd.AddFlags(fs)
	}
	if err := fs.Parse(args); err != nil {
		fs.Usage()
		os.Exit(1)
	}
	args = fs.Args() // reset to the remaining arguments

	ctx, err := NewContext(projectroot, gb.GcToolchain())
	if err != nil {
		return errors.Wrap(err, "unable to construct context")
	}
	defer ctx.Destroy()

	ctx.Debug("args: %v", args)
	return cmd.Run(ctx, args)
}
278062
func BuildSource(s string) *Source {
	var result []string
	var lineBuf bytes.Buffer
	for _, runeValue := range s {
		lineBuf.WriteRune(runeValue)
		if runeValue == '\n' {
			result = append(result, lineBuf.String())
			lineBuf.Reset()
		}
	}
	rest := lineBuf.String()
	// Stuff after last end-of-line (EOF or some more code)
	result = append(result, rest+"\n")
	return &Source{result}
}
1149751
func (m *Registry) GetSource(sourceType string) (Source, error) {
	return m.getDepth(0, sourceType)
}
1100748
func (c GetCmd) Run(ctx *cmd.Context) error {
	hookContext, ok := c.compContext.(downloader)
	if !ok {
		return errors.Errorf("invalid component context")
	}
	filePath, err := hookContext.Download(c.resourceName)
	if err != nil {
		return errors.Annotate(err, "could not download resource")
	}

	if _, err := fmt.Fprintf(ctx.Stdout, filePath); err != nil {
		return errors.Annotate(err, "could not write resource path to stdout")
	}
	return nil
}
95710
func (s *SourceService) CreateSource(ctx context.Context, source *platform.Source) error {
	return s.CreateSourceFn(ctx, source)
}
448063
func (r *RunListener) RunCommands(args RunCommandsArgs) (results *exec.ExecResponse, err error) {
	logger.Tracef("run commands: %s", args.Commands)
	return r.CommandRunner.RunCommands(args)
}