summary refs log tree commit diff stats
path: root/tools/atlas
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-09-06 13:19:11 +0200
committerGitHub <noreply@github.com>2021-09-06 13:19:11 +0200
commitcc5422ae5070a2cdd69dbd5b78663305623a0fbc (patch)
tree7443341b1a231a0534688eca342beace0f788430 /tools/atlas
parent73841ae194c795674fc7b67460ada9c18a292b8e (diff)
downloadNim-cc5422ae5070a2cdd69dbd5b78663305623a0fbc.tar.gz
Atlas: added 'extract' command, as promised (#18813)
Diffstat (limited to 'tools/atlas')
-rw-r--r--tools/atlas/atlas.nim10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/atlas/atlas.nim b/tools/atlas/atlas.nim
index 761ca5db8..370138029 100644
--- a/tools/atlas/atlas.nim
+++ b/tools/atlas/atlas.nim
@@ -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