aboutsummaryrefslogtreecommitdiff
path: root/src/main.nim
diff options
context:
space:
mode:
authorkitsunyan2018-04-23 18:19:54 +0000
committerkitsunyan2018-04-23 18:19:54 +0000
commit315d22cd30952916683dac0c38a24b73dba4b948 (patch)
tree8a1298ec92c13eb71d9343857566d44249d58217 /src/main.nim
parentb548155b950bf43d9d8de23c3b08efceff4be02a (diff)
Better "--print" support
Diffstat (limited to 'src/main.nim')
-rw-r--r--src/main.nim8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main.nim b/src/main.nim
index 045b44e..b259989 100644
--- a/src/main.nim
+++ b/src/main.nim
@@ -84,7 +84,9 @@ proc handleSync(args: seq[Argument], config: Config): int =
handleSyncSearch(args, config)
elif syncArgs.checkOpGroup(OpGroup.syncInstall) and
(args.check((some("u"), "sysupgrade")) or args.targets.len > 0):
- if currentUser.uid != 0 and config.sudoExec:
+ let printMode = args.check((some("p"), "print")) or args.check((none(string), "print-format"))
+
+ if currentUser.uid != 0 and config.sudoExec and not printMode:
let collectedArgs = @[sudoCmd, getAppFilename()] &
lc[x | (y <- args, x <- y.collectArg), string]
execResult(collectedArgs)
@@ -98,7 +100,7 @@ proc handleSync(args: seq[Argument], config: Config): int =
let noBuild = isNonDefaultRoot or isSkipDeps or isRootNoDrop
- if build and noBuild:
+ if not printMode and build and noBuild:
if isNonDefaultRoot:
printError(config.color, tr"non-default root path is specified" & " -- " &
tr"building is not allowed")
@@ -110,7 +112,7 @@ proc handleSync(args: seq[Argument], config: Config): int =
tr"building is not allowed")
1
else:
- let noaurAdd = noBuild and not noaur
+ let noaurAdd = not printMode and noBuild and not noaur
if noaurAdd:
if isNonDefaultRoot: