Giter Site home page Giter Site logo

Comments (7)

dearchap avatar dearchap commented on May 27, 2024 1

@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.

dearchap avatar dearchap commented on May 27, 2024

@Karmenzind what version of v2 are you using ? Also what are you setting the flag UsageText to ?

from cli.

Karmenzind avatar Karmenzind commented on May 27, 2024

Thanks for your reply. I just updated to 2.26.0 but got the same output:

image

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 \ns to the Usage like:

"\nedit configuration file with the default editor\n用默认编辑器打开配置文件\n"

But the first and the last one didn't work:
image

Seems that there is a Trim in your code. Maybe you can remove the Trim or only trim white spaces.

from cli.

dearchap avatar dearchap commented on May 27, 2024

@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.

Karmenzind avatar Karmenzind commented on May 27, 2024

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.

Karmenzind avatar Karmenzind commented on May 27, 2024

BTW, will the official v3 be released in the near future?

from cli.

Karmenzind avatar Karmenzind commented on May 27, 2024

Thanks.

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.