Global: add new unit related options

1. `--<module>-space-before-unit`
2. `--duration-abbreviation`
3. various code refactoring and cleanups
This commit is contained in:
李通洲
2025-07-30 14:30:36 +08:00
parent 8be419cfd6
commit a0174e8666
33 changed files with 556 additions and 174 deletions
+72 -1
View File
@@ -454,7 +454,8 @@
"remark": "Auto-detected based on isatty(1) by default",
"arg": {
"type": "bool",
"optional": true
"optional": true,
"default": false
}
},
{
@@ -500,6 +501,28 @@
"type": "color"
}
},
{
"long": "duration-abbreviation",
"desc": "Specify whether to abbreviate duration values",
"remark": "If true, the output will be in the form of \"1h 2m\" instead of \"1 hour, 2 mins\"",
"arg": {
"type": "bool",
"optional": true,
"default": false
}
},
{
"long": "duration-space-before-unit",
"desc": "Specify whether to put a space before the unit in duration values",
"arg": {
"type": "enum",
"enum": {
"default": "Use the default behavior of the module",
"always": "Always put a space before the unit",
"never": "Never put a space before the unit"
}
}
},
{
"long": "key-width",
"desc": "Align the width of keys to <num> characters",
@@ -623,6 +646,18 @@
"default": "light_red"
}
},
{
"long": "percent-space-before-unit",
"desc": "Specify whether to put a space before the percentage symbol",
"arg": {
"type": "enum",
"enum": {
"default": "Use the default behavior of the module",
"always": "Always put a space before the unit",
"never": "Never put a space before the unit"
}
}
},
{
"long": "bar-char-elapsed",
"desc": "Set the character to use in the elapsed part of percentage bars",
@@ -711,6 +746,18 @@
"default": "YB"
}
},
{
"long": "size-space-before-unit",
"desc": "Specify whether to put a space before the unit",
"arg": {
"type": "enum",
"enum": {
"default": "Use the default behavior of the module",
"always": "Always put a space before the unit",
"never": "Never put a space before the unit"
}
}
},
{
"long": "freq-ndigits",
"desc": "Set the number of digits to keep after the decimal point when printing CPU/GPU frequency in GHz",
@@ -719,6 +766,18 @@
"default": 2
}
},
{
"long": "freq-space-before-unit",
"desc": "Specify whether to put a space before the unit",
"arg": {
"type": "enum",
"enum": {
"default": "Use the default behavior of the module",
"always": "Always put a space before the unit",
"never": "Never put a space before the unit"
}
}
},
{
"long": "fraction-ndigits",
"desc": "Set the number of digits to keep after the decimal point when printing ordinary fraction numbers",
@@ -776,6 +835,18 @@
"type": "color",
"default": "light_red"
}
},
{
"long": "temp-space-before-unit",
"desc": "Specify whether to put a space before the unit",
"arg": {
"type": "enum",
"enum": {
"default": "Use the default behavior of the module",
"always": "Always put a space before the unit",
"never": "Never put a space before the unit"
}
}
}
],
"Module specific": [