59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
// Code generated by mcp-framework generate. DO NOT EDIT.
|
|
|
|
package mcpgen
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"strings"
|
|
|
|
fwupdate "forge.lclr.dev/AI/mcp-framework/update"
|
|
)
|
|
|
|
func UpdateOptions(version string, stdout io.Writer) (fwupdate.Options, error) {
|
|
return UpdateOptionsFrom(".", version, stdout)
|
|
}
|
|
|
|
func UpdateOptionsFrom(startDir string, version string, stdout io.Writer) (fwupdate.Options, error) {
|
|
manifestFile, _, err := LoadManifest(startDir)
|
|
if err != nil {
|
|
return fwupdate.Options{}, err
|
|
}
|
|
|
|
binaryName := strings.TrimSpace(manifestFile.BinaryName)
|
|
if binaryName == "" {
|
|
binaryName = BinaryName
|
|
}
|
|
|
|
return fwupdate.Options{
|
|
CurrentVersion: version,
|
|
Stdout: stdout,
|
|
BinaryName: binaryName,
|
|
ReleaseSource: manifestFile.Update.ReleaseSource(),
|
|
}, nil
|
|
}
|
|
|
|
func RunUpdate(ctx context.Context, args []string, version string, stdout io.Writer) error {
|
|
return RunUpdateFrom(ctx, args, ".", version, stdout)
|
|
}
|
|
|
|
func RunUpdateFrom(ctx context.Context, args []string, startDir string, version string, stdout io.Writer) error {
|
|
fs := flag.NewFlagSet("update", flag.ContinueOnError)
|
|
fs.SetOutput(io.Discard)
|
|
|
|
if err := fs.Parse(args); err != nil {
|
|
return err
|
|
}
|
|
if fs.NArg() != 0 {
|
|
return fmt.Errorf("update does not accept positional arguments: %s", strings.Join(fs.Args(), ", "))
|
|
}
|
|
|
|
options, err := UpdateOptionsFrom(startDir, version, stdout)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return fwupdate.Run(ctx, options)
|
|
}
|