Comments (7)
@Karmenzind Making something public is not something we would do lightly. If enough users requests them then perhaps. Also v2 is in maintenance mode so its probably not the best to make the change here. v3 is in alpha mode but you can use the releases right away.
from cli.
@Karmenzind what version of v2 are you using ? Also what are you setting the flag UsageText to ?
from cli.
Thanks for your reply. I just updated to 2.26.0 but got the same output:
I need to display English and Chinese text, so right align might look better.
Here's my code:
var um = map[string]string{
"text": "translate long query `TEXT` with e.g. --text=\"Long time ago\" 翻译长句",
"nocache": "don't use cached result 不使用本地词库,查询网络结果",
"theme": "choose the color theme for current query 选择颜色主题,仅当前查询生效",
"init": "initialize shell completion 初始化部分设置,例如shell的自动补全",
"server": "start server foreground 在前台启动服务端",
"daemon": "ensure/start the daemon process 启动守护进程",
"stop": "stop the daemon process 停止守护进程",
"update": "check and update kd client 更新kd的可执行文件",
"generate-config": "generate config sample 生成配置文件,默认地址为`~/.config/kd.toml`",
"edit-config": "edit configuration file with the default editor 用默认编辑器打开配置文件",
}
// ...create cli.App
&cli.BoolFlag{Name: "init", DisableDefaultText: true, Hidden: true, Usage: um["init"]},
&cli.BoolFlag{Name: "server", DisableDefaultText: true, Action: flagServer, Usage: um["server"]},
&cli.BoolFlag{Name: "daemon", DisableDefaultText: true, Action: flagDaemon, Usage: um["daemon"]},
&cli.BoolFlag{Name: "stop", DisableDefaultText: true, Hidden: true, Action: flagStop, Usage: um["stop"]},
&cli.BoolFlag{Name: "update", DisableDefaultText: true, Action: flagUpdate, Usage: um["update"]},
&cli.BoolFlag{Name: "generate-config", DisableDefaultText: true, Action: flagGenerateConfig, Usage: um["generate-config"]},
&cli.BoolFlag{Name: "edit-config", DisableDefaultText: true, Action: flagEditConfig, Usage: um["edit-config"]},
I tried inserting three \n
s to the Usage like:
"\nedit configuration file with the default editor\n用默认编辑器打开配置文件\n"
But the first and the last one didn't work:
Seems that there is a Trim
in your code. Maybe you can remove the Trim
or only trim white spaces.
from cli.
@Karmenzind You could define your Usage as a multiline string for example
&cli.StringFlag{
Name: "foo",
Usage: `foo1foo2
bar1bar2
`,
}
and the output will be something like
GLOBAL OPTIONS:
--foo value foo1foo2
bar1bar2
In the absence of that you would have to define a custom template and write some formatting yourself
from cli.
Thank you.
Inserting 2 tabs before the second line bar1bar2
did align the text. But it cannot automatically wrap the long text. I will try to customize the template later.
Hope you can make these variables public then users can rewrite a small part instead of the whole template.
from cli.
BTW, will the official v3 be released in the near future?
from cli.
Thanks.
from cli.
Related Issues (20)
- PersistentFlags support HOT 6
- Question about panic -> `After()` behaviour HOT 2
- v2: if custom subcommand completion is provided, completing after partial flag input panics HOT 5
- Compatibility for cli.Context and context.Context HOT 2
- IsSet breaks with Persistent option HOT 3
- [v3] `Required` does not work with `Persistent` HOT 2
- [v3] Missing `Required` flags show alias rather than primary name HOT 2
- [v3] `Validator` seems to always receive the empty string HOT 4
- [v3] Long flag usage text uses short flag syntax HOT 2
- [v3] how to chain multible Sources? HOT 11
- Execute `runFlagActions` before `c.Before` HOT 3
- `cli.UintSliceFlag` flags do not implement the `ActionableFlag` interface despite having an `Action` field
- Generate markdown from help HOT 3
- SliceFlagSeparator can affect subcommands, whereas DisableSliceFlagSeparator does not. HOT 1
- v3 MutuallyExclusive flags are not included in help text HOT 7
- FullName not working as it did in 2.19.3, seems to have broken in 2.20.0 HOT 3
- Categories with no visible flags are still visible HOT 1
- FilePath does not take precedence over EnvVar
- how to distinguish a flag between manually set or default settings ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.