我专门为此创建的课程是完全动态的:
https://github.com/2xsaiko/crogamp/blob/master/src/com/github/mrebhan/crogamp/cli/TableList.java
你可以这样使用它:
TableList tl = new TableList(3, "ID", "String 1", "String 2").sortBy(0).withUnicode(true);
// from a list
yourListOrWhatever.forEach(element -> tl.addRow(element.getID(), element.getS1(), element.getS2()));
// or manually
tl.addRow("Hi", "I am", "Bob");
tl.print();
使用 unicode 字符看起来像这样(注意:在控制台中看起来会更好,因为所有字符都一样宽):
┌─────────┬─────────────────────────────────────────────────────────────────────────┬────────────────────────────┐
│ Command │ Description │ Syntax │
┢━━━━━━━━━╈━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╈━━━━━━━━━━━━━━━━━━━━━━━━━━━━┪
┃ bye ┃ Quits the application. ┃ ┃
┃ ga ┃ Adds the specified game. ┃ <id> <description> <path> ┃
┃ gl ┃ Lists all currently added games ┃ [pattern] ┃
┃ gr ┃ Rebuilds the files of the currently active game. ┃ ┃
┃ gs ┃ Selects the specified game. ┃ <id> ┃
┃ help ┃ Lists all available commands. ┃ [pattern] ┃
┃ license ┃ Displays licensing info. ┃ ┃
┃ ma ┃ Adds a mod to the currently active game. ┃ <id> <file> ┃
┃ md ┃ Deletes the specified mod and removes all associated files. ┃ <id> ┃
┃ me ┃ Toggles if the selected mod is active. ┃ <id> ┃
┃ ml ┃ Lists all mods for the currently active game. ┃ [pattern] ┃
┃ mm ┃ Moves the specified mod to the specified position in the priority list. ┃ <id> <position> ┃
┃ top kek ┃ Test command. Do not use, may cause death and/or destruction ┃ ┃
┃ ucode ┃ Toggles advanced unicode. (Enhanced characters) ┃ [on|true|yes|off|false|no] ┃
┗━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
并且关闭 unicode 字符(省略 .withUnicode(true)):
Command | Description | Syntax
--------+-------------------------------------------------------------------------+---------------------------
bye | Quits the application. |
ga | Adds the specified game. | <id> <description> <path>
gl | Lists all currently added games | [pattern]
gr | Rebuilds the files of the currently active game. |
gs | Selects the specified game. | <id>
help | Lists all available commands. | [pattern]
license | Displays licensing info. |
ma | Adds a mod to the currently active game. | <id> <file>
md | Deletes the specified mod and removes all associated files. | <id>
me | Toggles if the selected mod is active. | <id>
ml | Lists all mods for the currently active game. | [pattern]
mm | Moves the specified mod to the specified position in the priority list. | <id> <position>
top kek | Test command. Do not use, may cause death and/or destruction |
ucode | Toggles advanced unicode. (Enhanced characters) | [on|true|yes|off|false|no]