ztzg opened a new pull request #1131: ZOOKEEPER-3599: cli.c: Introduce (optional) 'getopt' option parsing URL: https://github.com/apache/zookeeper/pull/1131 (This describes the "meat" of the PR. Please refer to the individual commit messages for additional details.) If POSIX or GNU `getopt` is available, use it to allow non-positional arguments in addition to the "old-style" positional ones. This patch aims to be backwards-compatible; both parsers give the following results: ./cli_st host:2181 => flags: 0, hostPort: host:2181, clientIdFile: (null), batchMode: 0, cmd: (null) ./cli_st host:2181 myid => flags: 0, hostPort: host:2181, clientIdFile: myid, batchMode: 0, cmd: (null) ./cli_st host:2181 cmd:mycmd => flags: 0, hostPort: host:2181, clientIdFile: (null), batchMode: 1, cmd: mycmd ./cli_st host:2181 cmd:mycmd -r => flags: 1, hostPort: host:2181, clientIdFile: (null), batchMode: 1, cmd: mycmd The newly-introduced "parser" enables the use of "option characters"; it notably defines `-r` (readonly), `-i <CLIENTID-FILE>`, and `-c <CMD>`: ./cli_st -r host:2181 => flags: 1, hostPort: host:2181, clientIdFile: (null), batchMode: 0, cmd: (null) ./cli_st -i myid host:2181 => flags: 0, hostPort: host:2181, clientIdFile: myid, batchMode: 0, cmd: (null) ./cli_st -i myid -c mycmd host:2181 => flags: 0, hostPort: host:2181, clientIdFile: myid, batchMode: 1, cmd: mycmd ./cli_st -i myid -c mycmd -r host:2181 => flags: 1, hostPort: host:2181, clientIdFile: myid, batchMode: 1, cmd: mycmd Note that the new parser does not try to prevent "silly" parses such as the following: ./cli_st -i myid -c mycmd host:2181 cmd:othercmd => flags: 0, hostPort: host:2181, clientIdFile: myid, batchMode: 1, cmd: othercmd ./cli_st -i myid -c mycmd host:2181 otherid => flags: 0, hostPort: host:2181, clientIdFile: otherid, batchMode: 1, cmd: mycmd
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services