diff --git a/README.md b/README.md index 99471cd9..c588de6d 100644 --- a/README.md +++ b/README.md @@ -128,54 +128,54 @@ in your shell’s init file. ``` Usage of powerline-go: -colorize-hostname - Colorize the hostname based on a hash of itself + Colorize the hostname based on a hash of itself -cwd-max-depth int - Maximum number of directories to show in path - (default 5) + Maximum number of directories to show in path + (default 5) -cwd-max-dir-size int - Maximum number of letters displayed for each directory in the path - (default -1) + Maximum number of letters displayed for each directory in the path + (default -1) -cwd-mode string - How to display the current directory - (valid choices: fancy, plain, dironly) - (default "fancy") + How to display the current directory + (valid choices: fancy, plain, dironly) + (default "fancy") -east-asian-width - Use East Asian Ambiguous Widths + Use East Asian Ambiguous Widths -error int - Exit code of previously executed command + Exit code of previously executed command -ignore-repos string - A list of git repos to ignore. Separate with ',' -Repos are identified by their root directory. + A list of git repos to ignore. Separate with ',' + Repos are identified by their root directory. -max-width int - Maximum width of the shell that the prompt may use, in percent. Setting this to 0 disables the shrinking subsystem. - (default 50) + Maximum width of the shell that the prompt may use, in percent. Setting this to 0 disables the shrinking subsystem. + (default 50) -mode string - The characters used to make separators between segments. - (valid choices: patched, compatible, flat) - (default "patched") + The characters used to make separators between segments. + (valid choices: patched, compatible, flat) + (default "patched") -modules string - The list of modules to load, separated by ',' - (valid choices: aws, cwd, docker, dotenv, exit, git, gitlite, hg, host, jobs, perlbrew, perms, root, ssh, time, user, venv) - (default "venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root") + The list of modules to load, separated by ',' + (valid choices: aws, cwd, docker, dotenv, exit, git, gitlite, hg, host, jobs, perlbrew, perms, root, ssh, time, user, venv) + (default "venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root") -newline - Show the prompt on a new line + Show the prompt on a new line -priority string - Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ',' - (valid choices: aws, cwd, cwd-path, docker, exit, git-branch, git-status, hg, host, jobs, perlbrew, perms, root, ssh, time, user, venv) - (default "root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path") + Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ',' + (valid choices: aws, cwd, cwd-path, docker, exit, git-branch, git-status, hg, host, jobs, perlbrew, perms, root, ssh, time, user, venv) + (default "root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path") -shell string - Set this to your shell type - (valid choices: bare, bash, zsh) - (default "bash") + Set this to your shell type + (valid choices: bare, bash, zsh) + (default "bash") -shorten-gke-names - Shortens names for GKE Kube clusters. + Shortens names for GKE Kube clusters. -theme string - Set this to the theme you want to use - (valid choices: default, low-contrast) - (default "default") + Set this to the theme you want to use + (valid choices: default, low-contrast) + (default "default") -truncate-segment-width int - Minimum width of a segment, segments longer than this will be shortened if space is limited. Setting this to 0 disables it. - (default 16) + Minimum width of a segment, segments longer than this will be shortened if space is limited. Setting this to 0 disables it. + (default 16) ``` diff --git a/main.go b/main.go index 014ea75c..7f74f765 100644 --- a/main.go +++ b/main.go @@ -104,89 +104,87 @@ var modules = map[string](func(*powerline)){ "venv": segmentVirtualEnv, } +func comments(lines ...string) string { + return " " + strings.Join(lines, "\n"+" \t ") +} + +func commentsWithDefaults(lines ...string) string { + return comments(lines...) + "\n" + " \t" +} + func main() { args := args{ CwdMode: flag.String( "cwd-mode", "fancy", - "How to display the current directory\n"+ - " (valid choices: fancy, plain, dironly)\n"+ - " "), + commentsWithDefaults("How to display the current directory", + "(valid choices: fancy, plain, dironly)")), CwdMaxDepth: flag.Int( "cwd-max-depth", 5, - "Maximum number of directories to show in path\n"+ - " "), + commentsWithDefaults("Maximum number of directories to show in path")), CwdMaxDirSize: flag.Int( "cwd-max-dir-size", -1, - "Maximum number of letters displayed for each directory in the path\n"+ - " "), + commentsWithDefaults("Maximum number of letters displayed for each directory in the path")), ColorizeHostname: flag.Bool( "colorize-hostname", false, - "Colorize the hostname based on a hash of itself"), + comments("Colorize the hostname based on a hash of itself")), EastAsianWidth: flag.Bool( "east-asian-width", false, - "Use East Asian Ambiguous Widths"), + comments("Use East Asian Ambiguous Widths")), PromptOnNewLine: flag.Bool( "newline", false, - "Show the prompt on a new line"), + comments("Show the prompt on a new line")), Mode: flag.String( "mode", "patched", - "The characters used to make separators between segments.\n"+ - " (valid choices: patched, compatible, flat)\n"+ - " "), + commentsWithDefaults("The characters used to make separators between segments.", + "(valid choices: patched, compatible, flat)")), Theme: flag.String( "theme", "default", - "Set this to the theme you want to use\n"+ - " (valid choices: default, low-contrast)\n"+ - " "), + commentsWithDefaults("Set this to the theme you want to use", + "(valid choices: default, low-contrast)")), Shell: flag.String( "shell", "bash", - "Set this to your shell type\n"+ - " (valid choices: bare, bash, zsh)\n"+ - " "), + commentsWithDefaults("Set this to your shell type", + "(valid choices: bare, bash, zsh)")), Modules: flag.String( "modules", "venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root", - "The list of modules to load, separated by ','\n"+ - " (valid choices: aws, cwd, docker, dotenv, exit, git, gitlite, hg, host, jobs, perlbrew, perms, root, ssh, time, user, venv)\n"+ - " "), + commentsWithDefaults("The list of modules to load, separated by ','", + "(valid choices: aws, cwd, docker, dotenv, exit, git, gitlite, hg, host, jobs, perlbrew, perms, root, ssh, time, user, venv)")), Priority: flag.String( "priority", "root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path", - "Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ','\n"+ - " (valid choices: aws, cwd, cwd-path, docker, exit, git-branch, git-status, hg, host, jobs, perlbrew, perms, root, ssh, time, user, venv)\n"+ - " "), + commentsWithDefaults("Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ','", + "(valid choices: aws, cwd, cwd-path, docker, exit, git-branch, git-status, hg, host, jobs, perlbrew, perms, root, ssh, time, user, venv)")), MaxWidthPercentage: flag.Int( "max-width", 50, - "Maximum width of the shell that the prompt may use, in percent. Setting this to 0 disables the shrinking subsystem.\n"+ - " "), + commentsWithDefaults("Maximum width of the shell that the prompt may use, in percent. Setting this to 0 disables the shrinking subsystem.")), TruncateSegmentWidth: flag.Int( "truncate-segment-width", 16, - "Minimum width of a segment, segments longer than this will be shortened if space is limited. Setting this to 0 disables it.\n"+ - " "), + commentsWithDefaults("Minimum width of a segment, segments longer than this will be shortened if space is limited. Setting this to 0 disables it.")), PrevError: flag.Int( "error", 0, - "Exit code of previously executed command"), + comments("Exit code of previously executed command")), IgnoreRepos: flag.String( "ignore-repos", "", - "A list of git repos to ignore. Separate with ','\n"+ - "Repos are identified by their root directory."), + comments("A list of git repos to ignore. Separate with ','", + "Repos are identified by their root directory.")), ShortenGKENames: flag.Bool( "shorten-gke-names", false, - "Shortens names for GKE Kube clusters."), + comments("Shortens names for GKE Kube clusters.")), } flag.Parse() if strings.HasSuffix(*args.Theme, ".json") {