Skip to content

Commit 81e5174

Browse files
Copilottoby
andcommitted
Update publisher CLI help output format to use standard output without timestamps and show flags in --long-flag/-short format
Co-authored-by: toby <[email protected]>
1 parent 68b5573 commit 81e5174

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

tools/publisher/main.go

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ func main() {
7777
}
7878

7979
func printUsage() {
80-
log.Println("MCP Registry Publisher Tool")
81-
log.Println()
82-
log.Println("Usage:")
83-
log.Println(" mcp-publisher publish [flags] Publish a server.json file to the registry")
84-
log.Println(" mcp-publisher create [flags] Create a new server.json file")
85-
log.Println()
86-
log.Println("Use 'mcp-publisher <command> --help' for more information about a command.")
80+
fmt.Fprint(os.Stdout, "MCP Registry Publisher Tool\n")
81+
fmt.Fprint(os.Stdout, "\n")
82+
fmt.Fprint(os.Stdout, "Usage:\n")
83+
fmt.Fprint(os.Stdout, " mcp-publisher publish [flags] Publish a server.json file to the registry\n")
84+
fmt.Fprint(os.Stdout, " mcp-publisher create [flags] Create a new server.json file\n")
85+
fmt.Fprint(os.Stdout, "\n")
86+
fmt.Fprint(os.Stdout, "Use 'mcp-publisher <command> --help' for more information about a command.\n")
8787
}
8888

8989
func publishCommand() {
@@ -100,6 +100,19 @@ func publishCommand() {
100100
publishFlags.BoolVar(&forceLogin, "login", false, "force a new login even if a token exists")
101101
publishFlags.StringVar(&authMethod, "auth-method", "github-oauth", "authentication method to use (default: github-oauth)")
102102

103+
// Set custom usage function
104+
publishFlags.Usage = func() {
105+
fmt.Fprint(os.Stdout, "Usage: mcp-publisher publish [flags]\n")
106+
fmt.Fprint(os.Stdout, "\n")
107+
fmt.Fprint(os.Stdout, "Publish a server.json file to the registry\n")
108+
fmt.Fprint(os.Stdout, "\n")
109+
fmt.Fprint(os.Stdout, "Flags:\n")
110+
fmt.Fprint(os.Stdout, " --registry-url string URL of the registry (required)\n")
111+
fmt.Fprint(os.Stdout, " --mcp-file string path to the MCP file (required)\n")
112+
fmt.Fprint(os.Stdout, " --login force a new login even if a token exists\n")
113+
fmt.Fprint(os.Stdout, " --auth-method string authentication method to use (default: github-oauth)\n")
114+
}
115+
103116
if err := publishFlags.Parse(os.Args[2:]); err != nil {
104117
log.Fatalf("Error parsing flags: %v", err)
105118
}
@@ -205,6 +218,28 @@ func createCommand() {
205218
return nil
206219
})
207220

221+
// Set custom usage function
222+
createFlags.Usage = func() {
223+
fmt.Fprint(os.Stdout, "Usage: mcp-publisher create [flags]\n")
224+
fmt.Fprint(os.Stdout, "\n")
225+
fmt.Fprint(os.Stdout, "Create a new server.json file\n")
226+
fmt.Fprint(os.Stdout, "\n")
227+
fmt.Fprint(os.Stdout, "Flags:\n")
228+
fmt.Fprint(os.Stdout, " --name/-n string Server name (e.g., io.github.owner/repo-name) (required)\n")
229+
fmt.Fprint(os.Stdout, " --description/-d string Server description (required)\n")
230+
fmt.Fprint(os.Stdout, " --repo-url string Repository URL (required)\n")
231+
fmt.Fprint(os.Stdout, " --version/-v string Server version (default: 1.0.0)\n")
232+
fmt.Fprint(os.Stdout, " --execute/-e string Command to execute the server\n")
233+
fmt.Fprint(os.Stdout, " --output/-o string Output file path (default: server.json)\n")
234+
fmt.Fprint(os.Stdout, " --registry string Package registry name (default: npm)\n")
235+
fmt.Fprint(os.Stdout, " --package-name string Package name (defaults to server name)\n")
236+
fmt.Fprint(os.Stdout, " --package-version string Package version (defaults to server version)\n")
237+
fmt.Fprint(os.Stdout, " --runtime-hint string Runtime hint (e.g., docker)\n")
238+
fmt.Fprint(os.Stdout, " --repo-source string Repository source (default: github)\n")
239+
fmt.Fprint(os.Stdout, " --env-var string Environment variable in format NAME:DESCRIPTION (can be repeated)\n")
240+
fmt.Fprint(os.Stdout, " --package-arg string Package argument in format VALUE:DESCRIPTION (can be repeated)\n")
241+
}
242+
208243
if err := createFlags.Parse(os.Args[2:]); err != nil {
209244
log.Fatalf("Error parsing flags: %v", err)
210245
}

0 commit comments

Comments
 (0)