[137675] branches/gsoc15-portfile

chunyang at macports.org chunyang at macports.org
Wed Jun 17 00:11:25 PDT 2015


Revision: 137675
          https://trac.macports.org/changeset/137675
Author:   chunyang at macports.org
Date:     2015-06-17 00:11:25 -0700 (Wed, 17 Jun 2015)
Log Message:
-----------
port-create: Add group option, support only github

Modified Paths:
--------------
    branches/gsoc15-portfile/README.md
    branches/gsoc15-portfile/port-create

Added Paths:
-----------
    branches/gsoc15-portfile/groups.json

Modified: branches/gsoc15-portfile/README.md
===================================================================
--- branches/gsoc15-portfile/README.md	2015-06-17 06:11:06 UTC (rev 137674)
+++ branches/gsoc15-portfile/README.md	2015-06-17 07:11:25 UTC (rev 137675)
@@ -1,5 +1,5 @@
 # port-create
 
 ## TODO
-- [-] Add option to write output to file
-- [ ] Add github group option
+- [x] Add option to write output to file
+- [x] Add github group option

Added: branches/gsoc15-portfile/groups.json
===================================================================
--- branches/gsoc15-portfile/groups.json	                        (rev 0)
+++ branches/gsoc15-portfile/groups.json	2015-06-17 07:11:25 UTC (rev 137675)
@@ -0,0 +1,7 @@
+{
+    "github": {
+        "PortGroup":  "github 1.0",
+        "setup": "author project version [tag_prefix]",
+        "tarball_from": "releases"
+    }
+}

Modified: branches/gsoc15-portfile/port-create
===================================================================
--- branches/gsoc15-portfile/port-create	2015-06-17 06:11:06 UTC (rev 137674)
+++ branches/gsoc15-portfile/port-create	2015-06-17 07:11:25 UTC (rev 137675)
@@ -34,6 +34,26 @@
     }
 }
 
+# jq(1) wrapper
+proc parse_group_json {query} {
+    set json groups.json
+    return [exec jq $query $json]
+}
+
+proc get_group {group} {
+    switch $group {
+        github {
+            set github(PortGroup)            [parse_group_json .github.PortGroup]
+            set github(github.setup)         [parse_group_json .github.setup]
+            set github(github.tarball_from)  [parse_group_json .github.tarball_from]
+            return [array get github]
+        }
+        default {
+            error "Unsupported group $group"
+        }
+    }
+}
+
 proc read_template {file} {
     set fp [open $file r]
     set template [read $fp]
@@ -53,10 +73,11 @@
     {url.arg      ""  "set the tarball URL of port"}
     {name.arg     ""  "set the name of port"}
     {version.arg  ""  "set the version of port"}
+    {group.arg    ""  "set the group of port"}
     {outfile.arg  ""  "write output to file"}
 }
 
-set usage ": $argv0 \[-url <url>] \[-name <name>] \[-version <version>] \[-outfile <outfile>]\noptions:"
+set usage ": $argv0 \[-url <url>] \[-name <name>] \[-version <version>] \[-group <group>] \[-outfile <outfile>]\noptions:"
 if {[catch {array set params [cmdline::getoptions ::argv $options $usage]}]} {
     puts [cmdline::usage $options $usage]
     exit 2
@@ -92,3 +113,8 @@
 } else {
     puts -nonewline $template
 }
+
+# Test github group option
+if {[expr {[string length $params(group)] > 0}]} {
+    puts [get_group $params(group)]
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150617/8cabe736/attachment.html>


More information about the macports-changes mailing list