Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix printing of help text for commandline options #425

Merged
merged 5 commits into from Jul 5, 2019

Conversation

Forgon2100
Copy link
Contributor

The commandline interface can print a usage message listing its options.
Its first line was untranslatable. This has been fixed.

When printing commandline option arguments, the help text could appear
misaligned in terminal output because of multibyte characters:

Usage: ../warzone2100/src/warzone2100 [OPTION...]
  --configdir=设定资料夹           设定设定资料夹
  --datadir=资料夹                   Add data directory
  --debug=debug level                   Show debug for given level
  --debugfile=档案                    将除错讯息输出至档案
  --flush-debug-stderr                  Flush all debug output written to stderr
  --fullscreen                          以全萤幕模式运行
  --game=level name                     Load a specific game mode
  -h, --help                            Show options and exit
  --help-all                            Show all options and exit
  --mod=mod                             开启global mod
  --mod_ca=mod                          开启战役模式
  --mod_mp=mod                          开启多人模式
  --noassert                            停用宣告
  --crash                               引发一个事故去进行一个事故处理程序测试
  --loadskirmish=储存游戏           Load a saved skirmish game
  --loadcampaign=储存游戏           Load a saved campaign game
  --window                              以视窗模式运行
  --version                             显示版本资讯及离开
  --resolution=宽 x 高                设定解析度
  --shadows                             开启影子
  --noshadows                           关闭影子
  --sound                               开启声音
  --nosound                             关闭声音
  --join=host                           Connect directly to IP/hostname
  --host                                Go directly to host screen
  --texturecompression                  启用纹理压缩
  --notexturecompression                禁用纹理压缩
  --autogame                            Run games automatically for testing
  --saveandquit=save name               Immediately save game and quit
  --skirmish=test                       Start skirmish game with given settings file

To solve this problem, the number of spaces between option arguments and
option summaries is reduced by the number of multibyte characters.
If the game is running with a Chinese or Korean locale, that number is
halved because CJK characters usually require two columns for printing.

The option --help had the single-dash alias -h, which has been removed.
It no longer omits some commandline switches, but lists all of them.
Consequently, the option --help-all has been removed as well.
Note that neither -h nor --help-all were documented in our man page.
Removing them makes commandline processing a bit easier.
To that end, a useless nullpointer variable for all commandline options
has also been removed.

After applying this PR, the terminal output in Chinese looks as below:

Usage: ../warzone2100/src/warzone2100 [OPTION...]
  --configdir=设定资料夹                设定设定资料夹
  --datadir=资料夹                      Add data directory
  --debug=debug level                   Show debug for given level
  --debugfile=档案                      将除错讯息输出至档案
  --flush-debug-stderr                  Flush all debug output written to stderr
  --fullscreen                          以全萤幕模式运行
  --game=level name                     Load a specific game mode
  --help                                Show options and exit
  --mod=mod                             开启global mod
  --mod_ca=mod                          开启战役模式
  --mod_mp=mod                          开启多人模式
  --noassert                            停用宣告
  --crash                               引发一个事故去进行一个事故处理程序测试
  --loadskirmish=储存游戏               Load a saved skirmish game
  --loadcampaign=储存游戏               Load a saved campaign game
  --window                              以视窗模式运行
  --version                             显示版本资讯及离开
  --resolution=宽 x 高                  设定解析度
  --shadows                             开启影子
  --noshadows                           关闭影子
  --sound                               开启声音
  --nosound                             关闭声音
  --join=host                           Connect directly to IP/hostname
  --host                                Go directly to host screen
  --texturecompression                  启用纹理压缩
  --notexturecompression                禁用纹理压缩
  --autogame                            Run games automatically for testing
  --saveandquit=save name               Immediately save game and quit
  --skirmish=test                       Start skirmish game with given settings file

The attached ZIP file contains

  • help texts in Chinese, English and German before and after this PR
  • a shell script to generate them

cli_help_documentation.zip

@KJeff01 KJeff01 added this to the 3.3.0_beta2 milestone Jul 3, 2019
Multibyte characters in commandline option arguments are compensated for
by printing less padding spaces before commandline option descriptions,
which prevents them from being misaligned in terminal output.

Fixes Warzone2100#425
* show all commandline options with --help

Fixes Warzone2100#425
* remove support for short options to simplify commandline parsing
* option --help remains, only its alias -h is removed

Fixes Warzone2100#425
@KJeff01 KJeff01 merged commit fad9124 into Warzone2100:master Jul 5, 2019
KJeff01 pushed a commit that referenced this pull request Jul 5, 2019
KJeff01 pushed a commit that referenced this pull request Jul 5, 2019
Multibyte characters in commandline option arguments are compensated for
by printing less padding spaces before commandline option descriptions,
which prevents them from being misaligned in terminal output.

Fixes #425
KJeff01 pushed a commit that referenced this pull request Jul 5, 2019
* show all commandline options with --help

Fixes #425
KJeff01 pushed a commit that referenced this pull request Jul 5, 2019
* remove support for short options to simplify commandline parsing
* option --help remains, only its alias -h is removed

Fixes #425
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.

None yet

2 participants