From 924a732b2ffb672ed56b39bb06239d0105323f4a Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sun, 29 Apr 2018 17:11:44 +0300 Subject: Use "-n" as short version of "--build" --- src/main.nim | 17 ++++++++++------- src/pacman.nim | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main.nim b/src/main.nim index d156834..fbf3364 100644 --- a/src/main.nim +++ b/src/main.nim @@ -159,12 +159,15 @@ proc handleUpgrade(args: seq[Argument], config: Config): int = commonOptions, transactionOptions, upgradeOptions) proc handleHelp(operation: OperationType) = - proc printHelp(command: string, text: string) = - if command.len > 14: - echo(' '.repeat(6), "--", command) + proc printHelp(pair: OptionPair, arg: Option[string], text: string) = + let shortPrefix = pair.short.map(s => " -" & s & ", ").get(' '.repeat(6)) + let longValue = arg.map(a => pair.long & " <" & a & ">").get(pair.long) + + if longValue.len > 14: + echo(shortPrefix, "--", longValue) echo(' '.repeat(23), text) else: - echo(' '.repeat(6), "--", command, ' '.repeat(15 - command.len), text) + echo(shortPrefix, "--", longValue, ' '.repeat(15 - longValue.len), text) let operationArgs = operations .filter(o => o.otype == operation) @@ -179,9 +182,9 @@ proc handleHelp(operation: OperationType) = if lines.len > 0: case operation: of OperationType.sync: - printHelp("build", tr"build targets from source") - printHelp("keyserver ", tr"use name as keyserver to receive keys from") - printHelp("noaur", tr"disable all AUR operations") + printHelp(%%%"build", none(string), tr"build targets from source") + printHelp(%%%"keyserver", some("name"), tr"use name as keyserver to receive keys from") + printHelp(%%%"noaur", none(string), tr"disable all AUR operations") else: discard diff --git a/src/pacman.nim b/src/pacman.nim index 2ad3560..f5df4e4 100644 --- a/src/pacman.nim +++ b/src/pacman.nim @@ -140,7 +140,7 @@ const o("u", "sysupgrade") + g(syncInstall), o("w", "downloadonly"), o("y", "refresh") + g(syncInstall, syncSearch, syncQuery), - $o("build") + g(syncInstall), + $o("n", "build") + g(syncInstall), $(^o("keyserver")) + g(syncInstall), $o("noaur") + g(syncInstall) ] -- cgit v1.2.3-70-g09d2