Skip to content

Conversation

@kou
Copy link

@kou kou commented Sep 20, 2025

Description

Add a CLI client command.

This is for decoupling third party Mozc clients such as uim and Fcitx5.

Mozc doesn't provide a client library. So third party Mozc clients can't be implemented without bundling Mozc. If we provide a CLI client command, third party Mozc clients can be implemented out of Mozc source.

This just:

  1. accepts mozc.commands.Input as input from stdin,
  2. sends the input to mozc_server as-is,
  3. receives mozc.commands.Output as output from mozc_server and
  4. outputs the output to stdout.

This may convert the protobuf binary format to/from something such as JSON Lines. This PoC just implements JSON Lines input/output. (No the protobuf binary format support.)

mozc_emacs_helper manages a client pool but this doesn't manage a client pool. If users need it, they must spawn multiple mozc_client_cli processes by themselves.

If there is any input error, mozc_client_cli exits with non-0 (1 in this implementation). Users can get error message from stderr.

Issue IDs

#1362 (comment) as a related discussion.

Steps to test new behaviors (if any)

A clear and concise description about how to verify new behaviors (if any).

  • OS: Debian GNU/Linux sid
  • Steps:
    1. bazelisk build package --config oss_linux --config release_build
    2. bazel-bin/unix/cli/mozc_client_cli
    3. Input mozc.commands.Input as JSON Lines to stdin

Example:

$ bazel-bin/unix/cli/mozc_client_cli
{"type": "GET_CONFIG"}
{"id":"0",...(GET_CONFIG response in JSON)}
{"type": "CREATE_SESSION"}
{"id":"1968337769025405287"}
^D
$
$ bazel-bin/unix/cli/mozc_client_cli
"X"
Failed to parse an input JSON as mozc.commands.Input: <"X">: INVALID_ARGUMENT: invalid JSON in mozc.commands.Input, near 1:1 (offset 0): unexpected character: '"'; expected '{'
$ echo $?
1

Additional context

This is just a PoC to discuss this direction.

This is for decoupling third party Mozc clients such as uim and
Fcitx5.

See also
google#1362 (comment)
as a related discussion.

This just:

1. accepts mozc.commands.Input as input from stdin,
2. sends the input to mozc_server as-is,
3. receives mozc.commands.Output as output from mozc_server and
4. outputs the output to stdout.

This may convert the protobuf binary format to/from something such as
JSON Lines. This PoC just implements JSON Lines input/output. (No
the protobuf binary format support.)

mozc_emacs_helper manages a client pool but this doesn't manage a
client pool. If users need it, they must spawn multiple
mozc_client_cli processes by themselves.

If there is any input error, mozc_client_cli exits with non-0 (1 in
this implementation). Users can get error message from stderr.

Example:

```console
$ bazel-bin/unix/cli/mozc_client_cli
{"type": "GET_CONFIG"}
{"id":"0",...(GET_CONFIG response in JSON)}
{"type": "CREATE_SESSION"}
{"id":"1968337769025405287"}
^D
$
```

```console
$ bazel-bin/unix/cli/mozc_client_cli
"X"
Failed to parse an input JSON as mozc.commands.Input: <"X">: INVALID_ARGUMENT: invalid JSON in mozc.commands.Input, near 1:1 (offset 0): unexpected character: '"'; expected '{'
$ echo $?
1
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant