From f227d1088f6a8aee3654804b5fd0110e15532c5b Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Thu, 7 Jun 2018 02:35:28 +0300 Subject: Add support for "-Sc" to clean package repositories --- src/common.nim | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/common.nim') diff --git a/src/common.nim b/src/common.nim index 1749ed7..36aae38 100644 --- a/src/common.nim +++ b/src/common.nim @@ -53,6 +53,13 @@ proc checkAndRefresh*(color: bool, args: seq[Argument]): tuple[code: int, args: else: (0, args) +proc noconfirm*(args: seq[Argument]): bool = + args + .filter(arg => arg.matchOption(%%%"confirm") or + arg.matchOption(%%%"noconfirm")).optLast + .map(arg => arg.key == "noconfirm").get(false) or + args.check(%%%"ask") + proc packageTargets*(args: seq[Argument], parseDestination: bool): seq[PackageTarget] = args.targets.map(target => (block: let (noDestinationTarget, destination) = if parseDestination: (block: @@ -451,6 +458,12 @@ proc reloadPkgInfos*(config: Config, path: string, pkgInfos: seq[PackageInfo]): template bareFullName*(bareKind: BareKind, bareName: string): string = $bareKind & "-" & bareName & ".git" +proc bareFullNameDeconstruct*(bareKind: BareKind, bareFullName: string): Option[string] = + if bareFullName.find($bareKind & '-') == 0 and bareFullName.rfind(".git") == bareFullName.len - 4: + some(bareFullName[($bareKind).len + 1 .. ^5]) + else: + none(string) + proc cloneBareRepo(config: Config, bareKind: BareKind, bareName: string, url: string, branchOption: Option[string], dropPrivileges: bool): Option[string] = let fullName = bareFullName(bareKind, bareName) -- cgit v1.2.3-70-g09d2