Fix linting errors in publisher CLI tool
Co-authored-by: toby <83556+toby@users.noreply.github.com>
This commit is contained in:
parent
e10d3f2b62
commit
68b55735cb
1 changed files with 36 additions and 28 deletions
|
|
@ -77,13 +77,13 @@ func main() {
|
|||
}
|
||||
|
||||
func printUsage() {
|
||||
fmt.Println("MCP Registry Publisher Tool")
|
||||
fmt.Println()
|
||||
fmt.Println("Usage:")
|
||||
fmt.Println(" mcp-publisher publish [flags] Publish a server.json file to the registry")
|
||||
fmt.Println(" mcp-publisher create [flags] Create a new server.json file")
|
||||
fmt.Println()
|
||||
fmt.Println("Use 'mcp-publisher <command> --help' for more information about a command.")
|
||||
log.Println("MCP Registry Publisher Tool")
|
||||
log.Println()
|
||||
log.Println("Usage:")
|
||||
log.Println(" mcp-publisher publish [flags] Publish a server.json file to the registry")
|
||||
log.Println(" mcp-publisher create [flags] Create a new server.json file")
|
||||
log.Println()
|
||||
log.Println("Use 'mcp-publisher <command> --help' for more information about a command.")
|
||||
}
|
||||
|
||||
func publishCommand() {
|
||||
|
|
@ -100,7 +100,9 @@ func publishCommand() {
|
|||
publishFlags.BoolVar(&forceLogin, "login", false, "force a new login even if a token exists")
|
||||
publishFlags.StringVar(&authMethod, "auth-method", "github-oauth", "authentication method to use (default: github-oauth)")
|
||||
|
||||
publishFlags.Parse(os.Args[2:])
|
||||
if err := publishFlags.Parse(os.Args[2:]); err != nil {
|
||||
log.Fatalf("Error parsing flags: %v", err)
|
||||
}
|
||||
|
||||
if registryURL == "" || mcpFilePath == "" {
|
||||
publishFlags.Usage()
|
||||
|
|
@ -203,7 +205,9 @@ func createCommand() {
|
|||
return nil
|
||||
})
|
||||
|
||||
createFlags.Parse(os.Args[2:])
|
||||
if err := createFlags.Parse(os.Args[2:]); err != nil {
|
||||
log.Fatalf("Error parsing flags: %v", err)
|
||||
}
|
||||
|
||||
// Validate required flags
|
||||
if name == "" {
|
||||
|
|
@ -225,7 +229,8 @@ func createCommand() {
|
|||
}
|
||||
|
||||
// Create server structure
|
||||
server := createServerStructure(name, description, version, repoURL, repoSource, registryName, packageName, packageVersion, runtimeHint, execute, envVars, packageArgs)
|
||||
server := createServerStructure(name, description, version, repoURL, repoSource,
|
||||
registryName, packageName, packageVersion, runtimeHint, execute, envVars, packageArgs)
|
||||
|
||||
// Convert to JSON
|
||||
jsonData, err := json.MarshalIndent(server, "", " ")
|
||||
|
|
@ -234,7 +239,7 @@ func createCommand() {
|
|||
}
|
||||
|
||||
// Write to file
|
||||
err = os.WriteFile(output, jsonData, 0644)
|
||||
err = os.WriteFile(output, jsonData, 0600)
|
||||
if err != nil {
|
||||
log.Fatalf("Error writing file: %v", err)
|
||||
}
|
||||
|
|
@ -300,7 +305,8 @@ func publishToRegistry(registryURL string, mcpData []byte, token string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func createServerStructure(name, description, version, repoURL, repoSource, registryName, packageName, packageVersion, runtimeHint, execute string, envVars []string, packageArgs []string) ServerJSON {
|
||||
func createServerStructure(name, description, version, repoURL, repoSource, registryName,
|
||||
packageName, packageVersion, runtimeHint, execute string, envVars []string, packageArgs []string) ServerJSON {
|
||||
// Parse environment variables
|
||||
var environmentVariables []EnvironmentVariable
|
||||
for _, envVar := range envVars {
|
||||
|
|
@ -351,13 +357,14 @@ func createServerStructure(name, description, version, repoURL, repoSource, regi
|
|||
description := fmt.Sprintf("Runtime argument %d", i+1)
|
||||
|
||||
// Try to provide better descriptions based on common patterns
|
||||
if strings.HasPrefix(arg, "--") {
|
||||
switch {
|
||||
case strings.HasPrefix(arg, "--"):
|
||||
description = fmt.Sprintf("Command line flag: %s", arg)
|
||||
} else if strings.HasPrefix(arg, "-") && len(arg) == 2 {
|
||||
case strings.HasPrefix(arg, "-") && len(arg) == 2:
|
||||
description = fmt.Sprintf("Command line option: %s", arg)
|
||||
} else if strings.Contains(arg, "=") {
|
||||
case strings.Contains(arg, "="):
|
||||
description = fmt.Sprintf("Configuration parameter: %s", arg)
|
||||
} else if i > 0 && strings.HasPrefix(parts[i], "-") {
|
||||
case i > 0 && strings.HasPrefix(parts[i], "-"):
|
||||
description = fmt.Sprintf("Value for %s", parts[i])
|
||||
}
|
||||
|
||||
|
|
@ -410,13 +417,14 @@ func smartSplit(command string) []string {
|
|||
for _, char := range command {
|
||||
switch {
|
||||
case char == '"' || char == '\'':
|
||||
if !inQuotes {
|
||||
switch {
|
||||
case !inQuotes:
|
||||
inQuotes = true
|
||||
quoteChar = char
|
||||
} else if char == quoteChar {
|
||||
case char == quoteChar:
|
||||
inQuotes = false
|
||||
quoteChar = 0
|
||||
} else {
|
||||
default:
|
||||
current.WriteRune(char)
|
||||
}
|
||||
case char == ' ' && !inQuotes:
|
||||
|
|
|
|||
Loading…
Reference in a new issue