11#! /bin/sh
22# / Usage: cargo <verb> [args...]
3- # / config [key [val]] List, get, or set config options.
4- # / install <pkgref> Install a package.
5- # / uninstall <pkgname> Uninstall a package.
3+ # / config [key [val]] List, get, or set config options.
4+ # / install <pkgref> Install a package.
5+ # / make-manifest <crate-file> <manifest-file> Generate a manifest.
6+ # / uninstall <pkgname> Uninstall a package.
67# /
78# / A 'pkgref' is any of:
89# / github:<username>/<reponame>[@<commit-id>] Fetch source from github.
1617# / cargo install file:$HOME/tmp/package.tar
1718# / cargo install uuid:83941200-18b3-41b1-8316-b98a2950b33a
1819# / cargo install http://www.leptoquark.net/~elly/rust-hello.tar
20+ # / cargo make-manifest hello.rc manifest
1921
2022die () {
2123 echo " $* "
@@ -177,6 +179,20 @@ c_install() {
177179 fi
178180}
179181
182+ # Generate a manifest file from a .rc file.
183+ # XXX: Don't parse the crate file this way!
184+ read_rc_attr () {
185+ sed -n " /$2 = \" /{s/.*$2 = \" \([^\" ]*\)\" .*/\1/;p}" " $1 "
186+ }
187+
188+ c_make_manifest () {
189+ name=$( read_rc_attr " $1 " name)
190+ vers=$( read_rc_attr " $1 " vers)
191+
192+ echo " name: $name " > $2
193+ echo " vers: $vers " >> $2
194+ }
195+
180196c_uninstall () {
181197 echo " Not implemented yet, sorry :(."
182198}
@@ -199,6 +215,9 @@ case "$cmd" in
199215 [ -z " $1 " ] && usage
200216 c_install " $@ "
201217 ;;
218+ make-manifest)
219+ c_make_manifest " $@ "
220+ ;;
202221 uninstall)
203222 c_uninstall " $@ "
204223 ;;
0 commit comments