Atlas: added 'extract' command, as promised (#18813)

This commit is contained in:
Andreas Rumpf 2021-09-06 13:19:11 +02:00 • committed by GitHub
commit cc5422ae50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,7 @@
## Simple tool to automate frequent workflows: Can "clone"
## a Nimble dependency and its dependencies recursively.
import std/[parseopt, strutils, os, osproc, unicode, tables, sets]
import std/[parseopt, strutils, os, osproc, unicode, tables, sets, json, jsonutils]
import parse_requires, osutils, packagesjson
const
@ -22,6 +22,8 @@ Usage:
Command:
clone url|pkgname clone a package and all of its dependencies
search keyw keywB... search for package that contains the given keywords
extract file.nimble extract the requirements and custom commands from
the given Nimble file
Options:
--keepCommits do not perform any `git checkouts`
@ -460,6 +462,12 @@ proc main =
of "search", "list":
updatePackages(c)
search getPackages(c.workspace), args
of "extract":
singleArg()
if fileExists(args[0]):
echo toJson(extractRequiresInfo(args[0]))
else:
error "File does not exist: " & args[0]
else:
error "Invalid action: " & action