Skip to content

Commit

Permalink
Improve formatting for help text
Browse files Browse the repository at this point in the history
Help text now expands on usage and default values for accepted
parameters, which should also help with providing configuration on the
Playground interface.
  • Loading branch information
deuill committed Apr 8, 2024
1 parent 97a84ab commit b1eed71
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions grawkit
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,10 @@ function parse_arguments(argc, argv, _, arg, i, option) {

arg = ltrim(argv[i], "-")
if (arg == "help") {
printf "Usage: grawkit [--help] "
printf "Usage: grawkit [OPTION]... [FILE]\nOptions:\n"
for (k in config) {
printf "[--%s] ", k
printf " --%s=\"%s\"\n \t%s\n", k, config[k], comment[k]
}
printf "[FILE]\n"
exit exit_code = 0
} else {
# Check if command-line option given corresponds to a configuration option, or stop
Expand Down Expand Up @@ -295,22 +294,35 @@ function rtrim(str, ch) {

BEGIN {
# Default configuration and command-line argument parsing.
config["default-branch"] = "master"
config["branch-spacing"] = "50"
config["branch-fill"] = "none"
config["branch-stroke-width"] = "10"

config["commit-spacing"] = "50"
config["commit-fill"] = "#fff"

config["label-spacing"] = "10"
config["label-round"] = "3"
config["label-fill"] = "#333"
config["label-text"] = "#fff"
config["label-font"] = "Inconsolata, Consolas, monospace"
config["label-font-size"] = "14"

config["palette"] = "#002b36,#268bd2,#859900,#cb4b16,#2aa198,#dc322f,#d33682,#6c71c4,#b58900"
config["default-branch"] = "master"
comment["default-branch"] = "The name of the pre-defined base branch."
config["branch-spacing"] = "50"
comment["branch-spacing"] = "The amount of space, in pixels, between branch tracks."
config["branch-fill"] = "none"
comment["branch-fill"] = "The color to fill branch tracks with."
config["branch-stroke-width"] = "10"
comment["branch-stroke-width"] = "The stroke width for branch track outlines."

config["commit-spacing"] = "50"
comment["commit-spacing"] = "The amount of space, in pixels, between commit stops."
config["commit-fill"] = "#fff"
comment["commit-fill"] = "The color to fill commit stops with."

config["label-spacing"] = "10"
comment["label-spacing"] = "The amount of space, in pixels, between each label."
config["label-round"] = "3"
comment["label-round"] = "The corner radius, in pixels, for labels."
config["label-fill"] = "#333"
comment["label-fill"] = "The color to fill labels with."
config["label-text"] = "#fff"
comment["label-text"] = "The color to use for label text."
config["label-font"] = "Inconsolata, Consolas, monospace"
comment["label-font"] = "The font to use for label text."
config["label-font-size"] = "14"
comment["label-font-size"] = "The font size to use for label text, in points."

config["palette"] = "#002b36,#268bd2,#859900,#cb4b16,#2aa198,#dc322f,#d33682,#6c71c4,#b58900"
comment["palette"] = "The colors to use for each branch track, in order."
parse_arguments(ARGC, ARGV)

# Errors.
Expand Down

0 comments on commit b1eed71

Please sign in to comment.