Add cmux CLI relay and tests
- Introduce CLI client (cmux) to relay v1 text and v2 JSON-RPC commands over Unix/TCP sockets - Implement command specs, flag parsing, v1/v2 round-trips, TCP retry with address refresh - Add browser subcommand mapping and rpc passthrough support - Support busybox-style invocation when argv[0]=="cmux" and add 'cli' subcommand - Add comprehensive unit tests for socket dialing, CLI commands, flag-to-param mapping, and env defaults - Add socket_addr file fallback reader and random request id generation
This commit is contained in:
parent
19707299f9
commit
1a1caca99d
3 changed files with 995 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var version = "dev"
|
||||
|
|
@ -30,6 +31,11 @@ type rpcResponse struct {
|
|||
}
|
||||
|
||||
func main() {
|
||||
// Busybox-style: if invoked as "cmux" (via symlink), act as CLI relay.
|
||||
base := filepath.Base(os.Args[0])
|
||||
if base == "cmux" {
|
||||
os.Exit(runCLI(os.Args[1:]))
|
||||
}
|
||||
os.Exit(run(os.Args[1:], os.Stdin, os.Stdout, os.Stderr))
|
||||
}
|
||||
|
||||
|
|
@ -59,6 +65,8 @@ func run(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
|
|||
return 1
|
||||
}
|
||||
return 0
|
||||
case "cli":
|
||||
return runCLI(args[1:])
|
||||
default:
|
||||
usage(stderr)
|
||||
return 2
|
||||
|
|
@ -69,6 +77,7 @@ func usage(w io.Writer) {
|
|||
_, _ = fmt.Fprintln(w, "Usage:")
|
||||
_, _ = fmt.Fprintln(w, " cmuxd-remote version")
|
||||
_, _ = fmt.Fprintln(w, " cmuxd-remote serve --stdio")
|
||||
_, _ = fmt.Fprintln(w, " cmuxd-remote cli <command> [args...]")
|
||||
}
|
||||
|
||||
func runStdioServer(stdin io.Reader, stdout io.Writer) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue